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
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.

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.