Post by supak111 » Wed Nov 18, 2020 3:10 pm

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.

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by sw!tch » Wed Nov 18, 2020 3:33 pm

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.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by supak111 » Wed Nov 18, 2020 3:52 pm

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

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by sw!tch » Wed Nov 18, 2020 4:19 pm

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.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by supak111 » Wed Nov 18, 2020 5:53 pm

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?

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by paulfeakins » Thu Nov 19, 2020 8:18 pm

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

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: Bing [Bot] and 82 guests