Reputation: 121
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
Upvotes: 9
Views: 44350
Reputation: 29
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.
Upvotes: 0
Reputation: 27
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
Upvotes: 1
Reputation: 9702
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
Upvotes: 6
Reputation: 207511
Open up a new tab
link
<a href="foo.html" target="_blank">linky</a>
pop up
window.open("foo.html", "_blank");
Upvotes: 6