Reply
close Popup Window
Old 03-31-2005, 08:08 PM close Popup Window
Tazmania's Avatar
Experienced Talker

Posts: 33
Location: Toronto, Canada
I have included popup windows in a site that I created. I need to know what code to include to automatically make the popup window close before another window can be opened.
All help greatly appreciated.

Tazmania
Tazmania is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-31-2005, 10:14 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
You could include this inside the popup window, causing it to close when it lost focus:
Code:
onBlur = self.close();
__________________
Free Teacher Websites
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 04-01-2005, 12:20 AM
simptech's Avatar
Skilled Talker

Posts: 81
Location: Cape Coral, Florida, United States
Adjust your popup function to reflect something similar to the following code

Code:
var my_window;
function popwin(url) {
if (!my_window.closed) my_window.close();
my_window = window.open(url,'popwin','width=400,height=275');
my_window.focus();
}
Unless you need to open the replacement window with different features, why not just re-use the same window?
__________________
PHPScripts4Free.com
FREE PHP scripts for your website!
simptech is offline
Reply With Quote
View Public Profile Visit simptech's homepage!
 
Old 04-01-2005, 09:04 PM
Tazmania's Avatar
Experienced Talker

Posts: 33
Location: Toronto, Canada
Thank you for the replies.

I have a question on where to put the code. My script for the popup is on the main page calling for the popups. It looks like this:
Tazmania is offline
Reply With Quote
View Public Profile
 
Old 04-01-2005, 09:08 PM
Tazmania's Avatar
Experienced Talker

Posts: 33
Location: Toronto, Canada
Thank you for the replies.

I have a question on where to put the code. My script for the popup is on the main page calling for the popups. It looks like this:
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function popUp2(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,men ubar=0,resizable=0,width=450,height=450,left = 640,top = 325');");
}

// End -->
I added this code for closing, based on the code you gave me:
var popUp2;
function popwin(url) {
if (!popUp2.closed) popUp2.close();
popUp2 = window.open(url,'popwin','width=400,height=275');
popUp2.focus();
}

I get a script error when I put it in. Any suggestions as to where I am going wrong?

Thanks in advance for the help.

Taz
Tazmania is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to close Popup Window
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.96132 seconds with 12 queries