I'm trying to make it so when you click on a link in an <iframe>
it will open the link in a new tab - not in the <iframe>
. Please note I do not have control of the content the people are viewing through the <iframe>
.
I'm trying to do this with javascript possibly, like $('a').setAttribute('target','_blank');
but it's not working out for me.
I also have in my HTML document <base target="_blank">
, that is not doing the trick too.
Is this impossible? Or am I just searching in the wrong places? Thanks in advance!
How do I do this? Thanks! By adding target="_blank" to the anchor, it will open it in a new tab. By adding target="_parent" to the anchor, it will open it up in the same window like a normal link.
Yes you can open a new Window from iFrame........
1 Expert Answer To force a single link from iframe to open in the parent window: add target="_PARENT" within that links anchor tag. To force ALL links from iframe to open in the parent window: add the base tag with target="_PARENT" in the head section of the iframe html page.
The iframe tag is used to display a web page inside a web page. When you create a document to be inside an iframe, any links in that frame will automatically open in that same frame.
To load all links on the page in the parent window use:
<base target="_parent" />
else in a new window use:
<base target="_blank" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With