W3C home > Mailing lists > Public > www-html@w3.org > June 2000

Re: hiding and showing layers in IE???

From: Serg Korzhinski <serg@snkey.net>
Date: Thu, 29 Jun 2000 19:19:35 -0400 (EDT)
Message-ID: <395BDA0D.B03C23DD@snkey.net>
To: Chau Huynh <Chau@autosoft-tool.com>, "www-html@w3.org" <www-html@w3.org>
> document.layer1.visibility = "hide";

It don't work not only in IE, in Netscape 6 too!
document.layers is not supported in IE and new NC, but you can use this
universal
function for setup layer:

function setObj(x) {
  var isNC=false;
  var isNC5=false;
  var vernum = parseInt(navigator.appVersion.charAt(0));
  var vendor = navigator.appName;
  if (vendor == "Netscape") isNC=true;
  if (isNC && (vernum>=5)) isNC5=true;
  var obj = eval(" (isNC) ? ( (isNC5) ? document.getElementById('"+x+"').style
: document."+x+" ) : document.all."+x+".style;");
  return obj;
 }

And call it like this:

var obj1= setObj('layer1');  // obj1 now refer to layer1
obj1.visibility='visible';   //make layer1 visible
obj1.visibility='hidden';   //make layer1 unvisible

This is working in all 4+ browsers!

Serge.
--
http://www.snkey.net
Received on Friday, 30 June 2000 02:14:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:43 GMT