Javascript : Why does this only work in ie and not mozilla or opera??

Czar

Lifer
Oct 9, 1999
28,510
0
0
function show(ln,option) {
var layer = document.getElementById(ln);
layer.style.visibility = option;
}

simple stuff that just changes the layer visibility on or off as in
show("layer1","visibile")
and this makes layer1 visible
and then hidden when its hidden

It works in ie and only in mozilla and opera when I change it to be like this

function show(ln,option) {
var layer = document.getElementById("layer1");
layer.style.visibility = option;
}

which is strange and stupid because then the point of this is gone
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
BTW, I could be breaking the standards here, but did you try:

ln.style.visibility = option;

?

Call it directly.
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
that doesnt work either :(

I would think IE is following it better, I mean whats the point of varibles if you cant do this
var stuff = 'layer1';
and then using the varible works the same as writing it in
 

kt

Diamond Member
Apr 1, 2000
6,015
1,321
136
for IE browsers, visibility = visible or hidden
for Mozilla based browsers, visibility = show or hide

although later versions of Mozilla will support visibility = visible or hidden, it's best to use show and hide instead.

 

joohang

Lifer
Oct 22, 2000
12,340
1
0
I think that it's better to follow the standard.

Linkie

Many people who use Mozilla probably will/know how to download a newer version any ways.
 

Czar

Lifer
Oct 9, 1999
28,510
0
0


<< BTW, what is "visibile"? ;)

Does that solve your problem? LOL :D
>>


hehe no that was just a typo there :p

what anoys me the most is that the built in layerhideshow in dreamweaver works and I have no idea how that works because its so darn complex
 

Czar

Lifer
Oct 9, 1999
28,510
0
0


<< for IE browsers, visibility = visible or hidden
for Mozilla based browsers, visibility = show or hide

although later versions of Mozilla will support visibility = visible or hidden, it's best to use show and hide instead.
>>


interesting but I'm using the newest version of mozilla and opera and still nothing
 

kt

Diamond Member
Apr 1, 2000
6,015
1,321
136
can we see your HTML portion for the layers? Netscape/Mozilla doesn't like you naming your layers using the "name" tag, use "id" tag instead.
 

Czar

Lifer
Oct 9, 1999
28,510
0
0


<< can we see your HTML portion for the layers? Netscape/Mozilla doesn't like you naming your layers using the "name" tag, use "id" tag instead. >>


I'm using id tags

its nothing more than just

<div id="layer1" style="background-color:red">fark</div>