Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to close a popup window on b

Status
Not open for further replies.

DeZiner

Programmer
May 17, 2001
815
US
:cool: I want to close a popup window on blur. The following code does it on the first instance of the popup, however if you click a link that opens the window a second time, it opens then closes and throws an error about callee canceled action canceled blah blah.

Also I have put in the popup
Code:
<body onblur=window.self.close()>
and this causes the window to close as soon as it opens. Why it is losing focus right away.....????

How can I use the following code but first and everytime see if the window exists or is an object, if not there do nothing, else run the script?
Code:
var fClose=0

function doClose(){ 
if(fClose)close(); 
} 

function _blur(){ 
fClose=1; 
setTimeout(&quot;doClose()&quot;,100); 
} 
</script> 


<body onblur=&quot;_blur()&quot;>
Remember this code doesn't work on the second instance of the window popup.

Thanks DeZiner
gear.gif width=45 align=left
When the gears stop turning,
we all stop learning.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top