hadoob024 Posted April 22, 2008 Share Posted April 22, 2008 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 More sharing options...
optikalefx Posted April 22, 2008 Share Posted April 22, 2008 does the page in the iframe ever change? you can access the dom of that frame document.getElementById("frame id").contentdocument; take a look at this http://www.w3schools.com/htmldom/prop_frame_contentdocument.asp Link to comment https://forums.phpfreaks.com/topic/102383-how-to-prevent-opening-in-new-window/#findComment-524317 Share on other sites More sharing options...
hadoob024 Posted April 22, 2008 Author Share Posted April 22, 2008 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. Link to comment https://forums.phpfreaks.com/topic/102383-how-to-prevent-opening-in-new-window/#findComment-524329 Share on other sites More sharing options...
optikalefx Posted April 22, 2008 Share Posted April 22, 2008 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. Link to comment https://forums.phpfreaks.com/topic/102383-how-to-prevent-opening-in-new-window/#findComment-524543 Share on other sites More sharing options...
hadoob024 Posted April 23, 2008 Author Share Posted April 23, 2008 Cool! That sounds like it should work. Link to comment https://forums.phpfreaks.com/topic/102383-how-to-prevent-opening-in-new-window/#findComment-524874 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.