admin管理员组文章数量:1202958
I have a website build in php, in some page i show a iframe with another website link, which displays it's login screen.
Both Websites are in different domain.
Like main website : Iframe href :
Now my users see a page in abcd where there is an iframe like
<iframe src="/" style="width:688px; height:384px;"></iframe>
Which displays the login screen of the xyz
Now what i want is, if users login to xyz another new tab should open with the homepage, after login of xyz and abcd tab should get close.
Is it possible to do with javascript or jquery, which works for all the browser including IE 7,8,9 ??
Thanks
I have a website build in php, in some page i show a iframe with another website link, which displays it's login screen.
Both Websites are in different domain.
Like main website : http://www.abcd.com Iframe href : http://www.xyz.com
Now my users see a page in abcd.com where there is an iframe like
<iframe src="http://www.xyz.com/" style="width:688px; height:384px;"></iframe>
Which displays the login screen of the xyz.com
Now what i want is, if users login to xyz.com another new tab should open with the homepage, after login of xyz.com and abcd.com tab should get close.
Is it possible to do with javascript or jquery, which works for all the browser including IE 7,8,9 ??
Thanks
Share Improve this question asked Feb 13, 2013 at 14:52 Rahul UkilRahul Ukil 1211 gold badge1 silver badge6 bronze badges 3- 2 You can not close windows/tabs that were not created with window.open. [There are hacks that work with some browsers, search stackoverflow] – epascarello Commented Feb 13, 2013 at 14:58
- okay, but is it possible to open tab the way i am thinking i explained above??? – Rahul Ukil Commented Feb 13, 2013 at 15:57
- you can replace the current tab with your iframe like in my answer – AbdelHady Commented Aug 27, 2013 at 14:53
4 Answers
Reset to default 6Open up a new tab
link
<a href="foo.html" target="_blank">linky</a>
pop up
window.open("foo.html", "_blank");
Put the following javascript code in the <head>
tag of the homepage of xyz.com (but don't put it in the login page if you still want to keep the login page inside the iframe):
<script type="text/javascript">
if (top.location!= self.location){
top.location = self.location
}
</script>
now, when opening the home page of xyz.com, this code will break the <iframe>
and changes the current tab from abcd.com to the home page of xyz.com
i dont know what you mean, but opening a new tab from iframe is just the normal code.
<a href="WebAdress.netdom" target="_blank"><button>Open New Tab</button></a>
hope this helps
What you're trying to do is impossible on your end, you only supply a login page inside the iFrame, therefor you cant control what the "login" button actually does, it's controlled by the other website.
The other website will need to edit the action themselves and add target='_blank', but that wont happen as their users will have another tab when they login.
本文标签: javascriptHow to Open a new tab from IframeStack Overflow
版权声明:本文标题:javascript - How to Open a new tab from Iframe? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738661853a2105473.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论