[thelist] simple Javascript help
Chris Marsh
chris at webbtech.co.uk
Fri Nov 1 11:19:00 CST 2002
> > Now, this works fine in IE, but Netscape complains about
> document.all
> > not existing.
> >
> > Can this be done in Netscape?
>
> The document.all object does not exist in Netscape, like the
> error indicated. Instead, use the getElementById function.
> Make sure that the elements have the id attribute set.
Or even better, do something a little like the followng:
function ElementObject(s) {
if(document.getElementById) {
var e = document.getElementById(s);
var o = 2;
}
else if(document.all) {
var e = document.all[s];
var o = 1;
}
else if(document.layers) {
var e = document.layers[s];
var o = 0;
}
this.ElementName = s;
this.ObjectSupport = o;
this.ElementO = e;
}
function StyleObject(s) {
var eo = new ElementObject(s);
var e = eo.ElementO;
var o = eo.ObjectSupport;
switch(o) {
case 2:
var t = e.style;
break;
case 1:
var t = e.style;
break;
case 0:
var t = e;
break;
}
this.StyleO = t;
}
Then...
var s = new StyleObject('id');
var so = s.StyleO;
so.visibility = 'visible';
HTH
Regards
Chris Marsh
More information about the thelist
mailing list