Re: Need Netscape visibility help

by Andrew McFarland <aamcf(at)aamcf.co.uk>

 Date:  Mon, 05 Aug 2002 22:14:52 +0100
 To:  <hwg-techniques(at)hwg.org>
 References:  woram
  todo: View Thread, Original
At 14:00 04/08/02 -0400, John Woram wrote:
>I have the following info in an image tag: <. img id="detail"
>style="visibility:hidden" ...> so the image is not visible when the
>page opens. I can toggle the image on and off by calling the following
>function:
>
>function toggle()
>{
>if {detail.style.visibility=="hidden") detail.style.visibility=""
>else detail.style.visibility="hidden";
>}
>
>This works fine in IE and Opera 6, but of course, not in Netscape 6.
>Would anyone know how to re-write the above so that it works in
>Netscape 6 only? If I can get it to work at all in Netscape, then I'll
>go back and add a browser sniffer that will choose the appropriate
>actions.

Don't use a browser sniffer; use an object sniffer, along the lines of:

if (document.getElementById) {
   // standards compliant code here
} else if (document.all) {
   // IE 4.x and 5.0 code
} else if (document.layers) {
   // Netscape 4 code, assuming you are using layers!
}

See http://aamcf.co.uk/temp/cascade for an example.

Andrew

--
http://aamcf.co.uk/

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA