Jump to content

How to PREVENT opening in new window?


hadoob024

Recommended Posts

Here's a problem I'm having.  I got my HTML page.  In this page I have an iframe.  The iframe is linked up to a page that I don't have control over, but what I want is that when someone clicks on a link in this iframe, that it replaces the what's in the iframe instead of opening a new window. 

 

Is this even possible considering that I don't have control over the code that's contained within the iframe?  If I do a view source on the page, I can see that they're doing a "target = _blank" to have this link open in a new window.  Is there anyway to prevent this from happening?  Thanks.

Link to comment
https://forums.phpfreaks.com/topic/102383-how-to-prevent-opening-in-new-window/
Share on other sites

Yup.  The page changes depending on the link prior to arriving at the page.  Basically, we have a job listing site.  Some job listings are in-house listings, in which case we just take them to our job listing page.

 

However, other listings that come up are pulled from outside listing sites.  When showing the listing, we show the listing stuff inside an iframe.  However, when a person clicks on a link to actually apply for that job, the whole "target = _blank" opens up a new window for that link.  What we want to be able to do is that when a person clicks on that link to apply for the job that the new window just replaces the contents of our iframe.  Is that possible with what you suggested?  I'm going to read over that link now.

yea, i dont use it often so by heart i wouldnt know the code but i know for the current dom to get all links its document.links;

 

so you could do something like var iframeLinks = document.getElementById("frameid").contentDocument.links;

and then run a for loop for (i=0;<= iframeLinks.length;i++)  and just change the target attribute of each link.

like iframeLinks.setAttribute("target", "_self");

 

something like that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.