May 14, 2000 - Clicking Away Windows
May 14, 2000 Clicking Away Windows Tips: May 2000
Yehuda Shiran, Ph.D.
|
<SCRIPT LANGUAGE="JavaScript">
<!--
function launchAbout() {
about = window.open("about.html", "about", "height=75,width=250");
return false;
}
// -->
</SCRIPT>
<A HREF="about.html" onClick="return launchAbout()">About</A>
You can close the new window by clicking anywhere inside it. We use the following script in the HEAD
portion of the about.html document:
<SCRIPT LANGUAGE="JavaScript">
<!--
function closeWin() {
window.close();
}
if (window.Event) document.captureEvents(Event.ONCLICK);
document.onclick = closeWin;
// -->
</SCRIPT>
For more information about events, refer to Column 9, The Navigator Event Model, Column 10, The Internet Explorer Event Model, and Column 11, The Cross-Browser Event Model. For a similar keyboard implementation, see Hot Keys (November 24, 1999). For a live demo, go to Tutorial 1.