Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 33
Location: Toronto, Canada
Trades: 0
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
 
 
Register now for full access!
Old 03-31-2005, 11:14 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
You could include this inside the popup window, causing it to close when it lost focus:
Code:
onBlur = self.close();
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Old 04-01-2005, 01:20 AM
simptech's Avatar
Skilled Talker

Posts: 81
Location: Cape Coral, Florida, United States
Trades: 0
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?
__________________

Please login or register to view this content. Registration is FREE

FREE PHP scripts for your website!
simptech is offline
Reply With Quote
View Public Profile
 
Old 04-01-2005, 10:04 PM
Tazmania's Avatar
Experienced Talker

Posts: 33
Location: Toronto, Canada
Trades: 0
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, 10:08 PM
Tazmania's Avatar
Experienced Talker

Posts: 33
Location: Toronto, Canada
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.20848 seconds with 12 queries