[Javascript] How to disable entire page when busy?

J. Lester Novros II lester at denhaag.org
Mon May 20 11:13:11 CDT 2002


Dear Alexander,

On 05/20/2002 05:53 AM, Alexander Yap wrote:
> Does anyone know how to easily disable a page such that it doesn't accept 
> user input (and preferably also grey out the page if possible)?

       [...]

> I need to support IE5+ and Netscape 6.2, so I can't rely on Netscape's 
> captureEvents() either.

Try using style settings of 'background-color: black;' and '-moz-opacity: .15;' 
  on the 'huge DIV'. The opacity thing is a Mozilla addition to the CSS spec 
they needed for their chrome stuff. The combination of the bgColor and the .15 
value should give you a partly transparent DIV which sort of 'grays out' the 
underlying page. I'm fairly sure Mozilla 0.9.4 [on which Netscape is based] 
supports it.

m$ has a similar kind of thing for xPloder called an 'alpha filter', more info 
to be found here:

http://msdn.microsoft.com/workshop/author/filter/reference/filters/alpha.asp

I assume this capacity is built in and not some sort of plug-in, which would 
rather defeat its purpose.

If you combine this with statements which set 'window.onkeypress' and 
'window.onclick' to point to a function which cancels the event and returns 
nothing, you should be home free, i.e. 'window.onkeypress = keypressHandler;' 
where 'keypressHandler' would be something like 'function keypressHandler(e) { 
e.stopPropagation(); return; }'. For xPloder the 'e.stopPropagation()' 
equivalent would be something like 'window.event.returnValue = false' if I'm not 
mistaken.

Be sure to restore mouse and keyboard input when you're done by setting the 
click and keypress handlers to a 'null' value [i.e. 'window.onclick = null;'].

I tested this on Mozilla 1.0rc2 and it works fine. I'm afraid I can't check 
xPloder since I'm running Linux.

Hope this helps anyway.

l8R lES
-- 
Attacks by Bill Gates on the General Public License have been driven by the fear
that the GPL creates a domain of software that m$ cannot privatize and control.
                                                                            ZDNet
http://open.denhaag.nu                                    http://www.denhaag.org




More information about the Javascript mailing list