I want to close two browser windows at the same time by clicking on one link in any of the two pages is it possible.
Announcement
Collapse
No announcement yet.
Answer me plz its urgent...
Collapse
X
-
If you opened the windows from a script with the "window.open()" method and named each window, you can close them from the parent window with...
<script>
<!--
function closeWin() {
window.close(myWin1);//myWin1 is the name of the 1st window
window.close(myWin2);//myWin2 is the name of the 2nd window
}
//-->
</script>
then in your html use this for the link.
<a href="javascript:closeWin()">Close both windows</a>
At least it should work, you may need quotes around the names, can't remember.
-
The code u gave is working fine when there are two windows which were opened by using the window.open(). But i want to close the two windows in which one is opened in the browser(parent window) and in that i have used the window.open() to open an new window. Now i want to close this both windows from the child window. Is it possible plz help me...
Comment
-
This is a shot in the dark, but it might work.
From the granchild window try this...
parent.window.parent.window.close()
parent.window.close();
I think if you try to close the original parent (grandparent) window an alert box pops up though.
Comment
-
it isn't possible to close the main browser window using javascript. it constitutes a security risk, and an invasion of privacy, so there are controls that prevent it from happening.
Comment
-
simple really...
I main window opens window 1, and window 1 opens window 2, and you want main window to close both, then define a function in window 1 code that closes window 2.
Then in main window, do:
window1.close_window2_function();
window1.close()
Comment
-
I found this whilst searching for a script and thought it better to follow in than open a new thread.
My site operates mainly from the first broser window that opens. Through necessity though, I do have a pop-up for more specific content.
What I need is to be able to load a page from a hyperlink in the pop-up in the main window whilst at the same time closing the pop-up.
be getle with me I'm only a learner
thanks"The day you stop learning is the day you become obsolete"! - my late Dad.
Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
Useful MySQL resource
Useful MySQL link
Comment
-
What I need is to be able to load a page from a hyperlink in the pop-up in the main window whilst at the same time closing the pop-up.
This should do the trick:
Code:<a href="whereever..." onclick="window.opener.location.href=this.href; window.close; return false;">A link</a>
Check out the Forum Search. It's the short path to getting great results from this forum.
Comment
-
Thanks but....
This is the link as copied from my page (having firstly inserted what you suggested.
<a class="standardlink" href="../../folder/document.htm" onclick="window.opener.location.href=this.href; window.close; return false;">
It does make the main window change to the desired display but it doesnt close the smaller window. Have I entered the line wrongly or wot?
thanks again.
Bazz"The day you stop learning is the day you become obsolete"! - my late Dad.
Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
Useful MySQL resource
Useful MySQL link
Comment
-
Another possibility: name the 'main' window:
<script type="text/javascript" language="javascript">
self.name = 'bazzWin';
</script>
(in all your pages). Then:
<a class="standardlink" href="../../folder/document.htm" target="bazzWin" onclick="if(opener&&!opener.closed)opener.location=this.href;self.close();return false;">
...in the pop-up.
Comment
-
Cheesebagpipe saw the problem, I left out the () on the window.close() call.Check out the Forum Search. It's the short path to getting great results from this forum.
Comment
-
Originally posted by cheesebagpipe
Hey Roy...shouldn't that be...
Give me ambivalence or give me something else
Check out the Forum Search. It's the short path to getting great results from this forum.
Comment
Comment