View previous topic :: View next topic |
Author |
Message |
newbie
Joined: 01 Oct 2004 Posts: 11
|
Posted: Thu Nov 11, 2004 5:03 pm Post subject: window.open JavaScript problem |
|
|
I have several links on my page which open popup windows with product details. I open the popup window with window.open JavaScript method.
I have button on the popup which executes window.close JavaScript method when it's clicked. My problem is that when the button is clicked I get ugly confirmation message from the browser that my program is trying to close the window.
Any way to avoid this message and directly close the popup? _________________ I'm still learning.. |
|
Back to top |
|
|
administrator Site Admin
Joined: 01 Oct 2004 Posts: 183
|
Posted: Fri Nov 12, 2004 9:50 am Post subject: |
|
|
Hi,
You can reference the parent window (the one that opened the popup) from the popup window with window.opener in JavaScript.
So if you open your popup like this on the parent page:
Code: |
<script>
oWin = window.open("http://www.your-site-here.com/your-page-here.htm","Your Window");
</script>
|
you can close it with the following call from the popup:
Code: |
<script>
window.opener.oWin.close();
</script>
|
By using the window.opener reference you are avoiding the warning JavaScript message coming from the popup
Cheers, _________________ Peter
ASP & ASP.NET Articles and Tutorials |
|
Back to top |
|
|
newbie
Joined: 01 Oct 2004 Posts: 11
|
Posted: Tue Nov 16, 2004 4:12 pm Post subject: |
|
|
Thanks!
The JavaScript popup behaves, as it should now _________________ I'm still learning.. |
|
Back to top |
|
|
Missie
Joined: 06 Feb 2006 Posts: 25
|
Posted: Wed Feb 08, 2006 7:36 pm Post subject: |
|
|
This is a cool tid bit. I think that I am going to start coping all the cool scrips off here and put them in a word document. Then when I can't remember something I can look in it and find it! This forum is really cool, full of really helpful people. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|