PDA

View Full Version : How do I force links in an iframe to open a new window (different web site domain)?



gwmbox
02-24-2016, 06:21 AM
I have been doing a fair bit of searching but so far I have not been able to get this to work for me.

I am trying to force links in a iframe to open either in a new window (_blank) or the top main window (_top)

I am trying to pull in a window from Redbubble and for all links to then open up in a new window or the top. I have got it to load where I want it to start displaying the content via the below css (for this specific page only thsu far)

html code


<div id="rb-div">
<iframe src="http://www.redbubble.com/people/michelle/works/3747892-fire-and-ice-siamese-cat-painting" id="rb-iframe" scrolling="no"></iframe>
</div>

css specific for this test iframe


#rb-div {width:100%;height:2000px;overflow:hidden;position:relative;}
#rb-iframe {position:absolute;top:-1450px;left:0px;width:100%;height:3450px;}

Cheers for your help :)

GW

jscheuer1
02-24-2016, 12:55 PM
There's nothing you can do unless you own the 3747892-fire-and-ice-siamese-cat-painting page or at least have control over how the links on it are coded to open. If you do, you can code them all to open as you like either globally (base target tag in the head of the page) or individually (target attributes for each link). These can also be coded using javascript, but again one needs access to the page. Same origin policy security feature of today's browsers prevents the top page from having any javascript control over the page in the iframe unless they are from the same domain.

gwmbox
02-25-2016, 01:09 AM
Bugger :(, but thanks for the reply