Closed Thread Icon

Topic awaiting preservation: does this work? (layers) (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8331" title="Pages that link to Topic awaiting preservation: does this work? (layers) (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: does this work? (layers) <span class="small">(Page 1 of 1)</span>\

 
Gweilo
Bipolar (III) Inmate

From: switzerland
Insane since: Sep 2002

posted posted 10-03-2002 15:38

hi, I'm trying to pass layernames in a function, and that function will set the layer to visible

code:
if (N)
{
var h="hide";
var v="show";
}
else {
var h="hidden";
var v="visible";
}

function zeigen()
{
args=zeigen.arguments.length;
for (j=0;j<args;j++)
{
if (DOM)document.getElementById(zeigen.arguments[j]).style.visibility=v;
if (I) zeigen.arguments[j].style.visibility=v;
if (N) zeigen.arguments[j].style.visibility=v;
}

}



for DOM it works, but for IE and N < 6? I'm asking, because I cant test it (don't have the old browsers anymore).
I would call the function like this:
zeigen("layername","secondlayer");

thank you in advance



[This message has been edited by Gweilo (edited 10-03-2002).]

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 10-03-2002 16:23

It might work for earlier version of IE depending on what "zeigen.arguments" is.

IE 4 uses:
document.all['layerId'].style.visibility = value

But it won't work for netscape. Your setting:
YourReference.style.visibility = value

Netscape 4 doesn't use the .style bit. The NN4 property for visibility is:
document.layers['layerId'].visibility = value

Edit: Oh and you can still download Netscape 4 from www.netscape.com . But it's user stats are aparently below 1% nowadays so why bother.


You can also pass the visibility setting if coded the function more like this:

<BLOCKQUOTE><FONT face="Verdana, Arial">code:</font><HR><pre>function layerVisibility (id, vis) { // vis can be 'show', 'hide', or 'switch'

if (ns4) {obj = document.layers[id]}
else if (ie4) {obj = document.all[id].style}
else if (dom) {obj = doucment.getElementById(id).style}

if (vis=='show') {(ns4)? null : vis = 'visible'}
if (vis=='hide') {(ns4)? null : vis = 'hidden'}
if (vis=='switch') {(obj.visibility == ('visible'

Gweilo
Bipolar (III) Inmate

From: switzerland
Insane since: Sep 2002

posted posted 10-03-2002 16:53

oh, I had a typo in the code. the Netscape section should have been:
window.document.zeigen.arguments[j].visibility=v;

but, this won't work - what I actually assumed.

hm. The ID, do you mean the layer number, or just the ID (layername)?
e.g. will this work in NS 4?
if (ns4) {obj = document.layers[id]}

Is it possible to use the layer numbers instead of the names? (especially for DOM)


Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 10-03-2002 17:03

window.document.[arguments[j]].visibility=v;


will work for NN. ('layers' isn't necessary, btw.)

« BackwardsOnwards »

Show Forum Drop Down Menu