Onblur closes Popup

[Total: 0    Average: 0/5]

This will close a popup window if focus removed.

Head Code:

<SCRIPT LANGUAGE=JavaScript> 
MyWin= null; 
function Oui(){ 
  if(!MyWin){MyWin= window.open("http://www.js-examples.com/","Blah","top=200,left=300,height=200,width=200")} 
  else{ 
    MyWin.close();MyWin=null; 
    MyWin= window.open("http://www.js-examples.com/","Blah","top=200,left=300,height=200,width=200") 
  } 
} 
function Non(){ 
  if(MyWin){MyWin.close();MyWin=null} 
  else{MyWin=null}  
} 
</script> 

Body Code:

<BODY onfocus="JavaScript:Non()" onblur="JavaScript:MyWin=null"> 
<a HREF="javascript:Oui()">Click here to open window!</a> 
<BR>
if window is open - click here to close it

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *