Checking Before Closing a Window : Window : Window Browser JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Window Browser » Window »

 

Checking Before Closing a Window




<HTML>
<HEAD>
<TITLE>window.closed Property</TITLE>
<SCRIPT LANGUAGE="JavaScript">
var newWind;
var isIE3 = (navigator.appVersion.indexOf("MSIE 3"!= -1true false;

function newWindow() {
    newWind = window.open("","subwindow","HEIGHT=200,WIDTH=200")
    if (newWind.opener == null) {
        newWind.opener = window
    }
    setTimeout("finishNewWindow()"100)
}
function finishNewWindow() {
    var output = ""
    output += "<HTML><BODY><H1>A Sub-window</H1>"
    output += "<FORM><INPUT TYPE='button' VALUE='Close Main Window'"
    output +="onClick='window.opener.close()'></FORM></BODY></HTML>"
    newWind.document.write(output)
    newWind.document.close()
}


function closeWindow() {
    if (isIE3) {
        newWind = window.open("","subwindow","HEIGHT=200,WIDTH=200")    
    }
    if (newWind && !newWind.closed) {
        newWind.close()
    }
}
</SCRIPT>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE="button" VALUE="Open Window" onClick="newWindow()"><BR>
<INPUT TYPE="button" VALUE="Close it if Still Open" onClick="closeWindow()">
</FORM>
</BODY>
</HTML>

           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Window Browser
» Window