Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q676 How can I control the opening and closing of a popup window using a checkbox?

You are here: irt.org | FAQ | JavaScript | Window | Q676 [ previous next ]

First the form:

<SCRIPT LANGUAGE="JavaScript"><!--
function myWindow(openWindow) {
    if (openWindow) {
        windowHandle = window.open('mypage.htm','windowName','width=200,height=200');
        if (!windowHandle.opener)
            windowHandle.opener = self;
    }
    else
        windowHandle.close();
}
//--></SCRIPT>

<FORM NAME="myForm">
<INPUT NAME="myCheckbox" TYPE="CHECKBOX" onClick="myWindow(this.checked)">
</FORM>

Then in the new window:

<BODY onUnload="opener.document.myForm.myCheckbox.checked = false">

©2018 Martin Webb