Page 1 of 1

Any easy way to add to all homepage href links target=_top?

Posted: Wed Nov 18, 2020 3:10 pm
by supak111
Wondering if there is any easy way to add to all homepage href links: target=_top

Want to do this to "break out of frame" for when other websites display my site in an iFrame. I've tried some JavaScript tricks to break out of there frame but they didn't wont.

Re: Any easy way to add to all homepage href links target=_top?

Posted: Wed Nov 18, 2020 3:33 pm
by sw!tch
Are you wanting to allow sites to embed your website in iframes? If not you should review your Content Security Policy and also take a look at X-Frame-Options, which you can pass in your header.

Re: Any easy way to add to all homepage href links target=_top?

Posted: Wed Nov 18, 2020 3:52 pm
by supak111
I want them to be able to put my site in an iframe i just want as soon as someone click on any links in the iframe that the links open in a target=_top aka a new tab.

Just need to know what file I need to edit in OC3 to make all homepage href/links have this in them target=_top

Re: Any easy way to add to all homepage href links target=_top?

Posted: Wed Nov 18, 2020 4:19 pm
by sw!tch
a href tags are not generated dynamic in default OC, there is no single file. You would most likely have to edit your twig files, common/header, common/menu, etc... and append target.

Might be possible to do something in bulk by creating an event and use PHP DOM manipulation. Downside is it could increase load on the server if you have a huge amount links being generated.

Re: Any easy way to add to all homepage href links target=_top?

Posted: Wed Nov 18, 2020 5:53 pm
by supak111
No really sure why JS wasn't working, I tested a few JS methods on a free wix.com site. Do you know of a good JS break out of frame script?

Re: Any easy way to add to all homepage href links target=_top?

Posted: Thu Nov 19, 2020 8:18 pm
by paulfeakins
supak111 wrote:
Wed Nov 18, 2020 3:10 pm
for when other websites display my site in an iFrame
Does this happen a lot?