Modal JavaScript windows
There does not seem to be a unified way of creating a modal window. Web sources have told me that Mozilla and Opera supports a "modal=yes" attribute in it's window.open argument string, whereas Internet Explorer supports an showModal-method. Issues include, however, Mozilla's inability to keep the modal window on top, whereas Internet Explorer's approach disables access to global variables in the opening window, thus limiting the functionality.
I have come up with an alternate approach:
function OnBlurEventHandler()
{
window.focus();
if(window.attachEvent) window.opener.attachEvent("onfocus", OnBlurEventHandler);
else if(window.addEventListener) window.opener.addEventListener("focus", OnBlurEventHandler, false);
}
if(window.attachEvent) window.opener.attachEvent("onfocus", OnBlurEventHandler);
else if(window.addEventListener) window.opener.addEventListener("focus", OnBlurEventHandler, false);
The above script subscribe to its opener's "focus" event and forces itself to focus whenever the parent gets focus.
Make sure you include a close button ;-)
Comments