June 13, 2000 - Modal Windows in Netscape | WebReference

June 13, 2000 - Modal Windows in Netscape

Yehuda Shiran June 13, 2000
Modal Windows in Netscape
Tips: June 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

JavaScript features several built-in dialog boxes: window.alert(), window.confirm(), and window.prompt(). When a dialog box pops up, the user cannot focus on the original page until the box is terminated. In other words, a dialog box is always focused. Internet Explorer supports a few methods that enable you to apply this feature to any new window:

showModalDialog() (Internet Explorer 4 and above)
showModelessDialog() (Internet Explorer 5 and above)
You can achieve a similar effect in Navigator by specifying the onBlur event handler:

<BODY onBlur="window.focus()">

If you use the above event handler in the <BODY> tag, the window holding the document remains focused until the user closes it. There are several differences between this Navigator-only technique and Internet Explorer's showModalDialog() method. First of all, the focused window isn't associated with a specific window (or document). That is, the user cannot bring up any other browser window, even if it isn't the window that opened the dialog window. In addition, the user can still bring up a different window for a moment, which is enough to close the opener window while the "modal" dialog is open.

For more on modal windows, go to Working with Windows - Dialog Boxes.