Re: "error on page"
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: "error on page"

From: RobG <rgqld@iinet.net.auau>
Date: Fri Jul 22 2005 - 06:17:38 CEST

Lee David wrote:
>>For the sake of the exercise:
>>
>> var supportForLayers = !!document.layers;
>>
>>The use of !! forces the result to be explicitly true or false and have
>>the right sense.
>>
>
>
> I'm using <div> to enclose the text that I want to appear. I understand
> that Layers is an older and not needed technology. However, the check for
> it indicates the usage of NS which used totally different values than IE
> does. Therefore, I'm assuming I could use the above and then have code like
> this:
>
> if (supportForLayers)
> {
> turn on the various <div> based on which object incurred the mouseover or
> mouseout event using "show"
> turn off the various <div> that are not applicable to the triggering event
> using "hide"
> }
>
> if (supportForAll)
> {
> turn on the various <div> based on which object incurred the mouseover or
> mouseout event using "visible"
> turn off the various <div> that are not applicable to the triggering event
> using "hidden"
> }

That's the right strategy, only test for the most common choice first -
Communicator 4 represents perhaps 1:1000 web surfers, so do the test
that will be true for the vast majority of cases first.

   function setVisibility ( el, state ) {
     if ( el.style ) {
       el.style.visibility = ('visible'==state)? 'visible' : 'hidden';
     } else if ( el.visibility ) {
       el.visibility = ('visible'==state)? 'show' : 'hide';
     } else {
       // Some other option?
     }
   }

If the above is called with:

    setVisibility ( elementReference, 'visible' );

it will change the visibility property to visible or show. Anything
else and it will be changed to hidden or hide.

I don't have Communicator 4 handy so I can't test it, but it should be OK.

>
> Would I need something for Opera, Firefox or other modzilla browsers?

No. The idea is to test for functionality, not browser.

-- 
Rob
Received on Tue Oct 18 02:59:40 2005