ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

window.open JavaScript problem

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> JavaScript / DHTML / HTML / CSS
View previous topic :: View next topic  
Author Message
newbie



Joined: 01 Oct 2004
Posts: 11

PostPosted: Thu Nov 11, 2004 5:03 pm    Post subject: window.open JavaScript problem Reply with quote

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
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Fri Nov 12, 2004 9:50 am    Post subject: Reply with quote

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 Smile



Cheers,
_________________
Peter
ASP & ASP.NET Articles and Tutorials
Back to top
View user's profile Send private message
newbie



Joined: 01 Oct 2004
Posts: 11

PostPosted: Tue Nov 16, 2004 4:12 pm    Post subject: Reply with quote

Thanks!

The JavaScript popup behaves, as it should now Wink
_________________
I'm still learning..
Back to top
View user's profile Send private message
Missie



Joined: 06 Feb 2006
Posts: 25

PostPosted: Wed Feb 08, 2006 7:36 pm    Post subject: Reply with quote

This is a cool tid bit. Smile 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! Smile This forum is really cool, full of really helpful people. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> JavaScript / DHTML / HTML / CSS All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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

SQL Tutorial