I have developed a pop up extension for google chrome. I have added an iframe in that popup. Now when i try to open a link from that iframe.. its not working.. its not even working within the iframe itself. i need the links in iframe to be opened in a new tab.
I tried writing some scripts which can change href in a to be opened in a new tab or in the same tab. But how to do that for an iframe.
Note: The page loaded in iframe is in my control and can be changed if needed.
Put <base target="_blank"/> into <head> of that iframe. You can also mark individual links with target="_blank".
Related
I have added an iframe to my webpage that is used for converting video links to mp3 format.
iframe shows a button that, when clicked, opens a new tab before starting to download the wanted mp3 file. I would like to know if there is a way in javascript to close that newly opened tab to ensure a better user experience. I know that window.close() can do that, but not sure if we can apply that to a tab opened by a script from an iframe.
This is the iframe in question, It sends a get request to the link specified in the src attribute.
<iframe id="downloadIframe" src="https://loader.to/api/button/?url=${vidLink}&f=mp3&color=0964D3"></iframe>
When the iframe is loaded, you can see this in the code it loads with it:
<a id="downloadButton" onclick="onClick();window.open('https://loader.to/ajax/a.php');" href="#">
I believe that the opened window is caused by window.open().
Knowing that I cant change the code that is within an iframe, any idea how I can close that tab?
Open the dowlnoad in a iframe instead of a tab.
Then you can later drop the iframe from the DOM making it disappear.
you can block the iframe from opening new tabs by using the sandbox attribute.
sandbox=""
Sandbox Applies extra restrictions to the content in the frame. The value of the attribute can either be empty to apply all restrictions or space-separated tokens to lift particular restrictions.
You can read more about it here
In My application on click of a link i open one POPUP window which has one button which opens another POPUP window, which has one Iframe and one dropdown for language. On change of dropdown iFrame body gets changed dynamically like below
$('#tncFrame').contents().find('body')[0].innerHTML="<base target='_blank'/>" + $scope.tncFileContent;
$scope.tncFileContent this is a dynamic html content.
I have prefixed <base target='_blank'/> to the html so that links in the dynamic html content open in new window.
IN FF and Chrome its working fine but not in IE. Can anyone help me out.
Thanks
In IE 11, only links to the same domain work in IFRAMEs. Linking to domains other than the one the page loaded from is prohibited now. Links with target=_blank attribute are ignored unless they are pointing to the domain from which the page loaded. I have tested this with Google's reCAPTCHA and it is true.
I wrote about this yesterday in a blog article on my site.
http://rickcable.blogspot.com/2018/03/internet-explorer-11-and-google-captcha.html
open in new window
link 1
link 2
link 3
<iframe name="blah" src="blah.html" ></iframe>
I have a page with an iframe in it. I have links that open pages inside the iframe, so the iframe doesn't have just one constant source. I want there to be a link that will open whatever source is currently in the iframe into a new window, whether it be 1.html, 2.html, or 3.html, etc (more pages will constantly be added so there won't just be three in the future).
How would I implement this link? Thank you so much in advance! :~)
Try this,
$(function(){
$('a[target="blah"]').on('click',function(e){
e.preventDefault();
window.open(this.href,'blah');
});
});
I just need one thing. How to make "iframe page" to open their links in new tab.
I try to add target="_blank" but I think that is not iframe attribute.
My code open one webcam site. I want, when someone click on "sign up" to be opened in new tab...
The only real solution is to either have target="_blank" bound to specific links, or if you control the page that you're loading in the iframe, making sure that page has a <base target="_blank"> element on it, which makes all a elements link through a new tab/window
What's wrong with target="_blank"? It works no matter where the link is.
do you mean " links that are in a page that is loaded in a iframe" ?
if so , I'm not sure such a thing exists in html 4 . it depends on browser I think . firefox , chrome , opera open _blank in new tab but IE opens it in new window
This is a tricky one. I have a link on my page that opens a Colorbox iframe to an external website. The external website contains links to another page. When the user clicks those links, I need them to load up in the same iframe.
The problem is, the link on that external site is set to open a new window with target="_blank". Therefore, instead of this page loading within the same colorbox iframe like I need it to, it opens a totally new window.
Is there any way to bypass it so that these links within the iframe do not open a new window, and instead load that window within the same colorbox iframe?
Thanks in advance!
_blank will always open a new window, you could try _TOP instead, it should work something like this;
<a onclick="parent.$.fn.colorbox.close();" href="NEW SITE" target="_top">
open in parent window with animation
</a>
Do you control the document that is being displayed in the iframe? If so you could handle things a little differently so that you only opened new windows if the document isn't being displayed in an iframe. But if the document you are iframing isn't under your control then I don't think there is anything you can do about it.