Hi,
Can someone tell me how I hide a layer when someone clicks a link? I used to know how but I forget. :)
Thanks,
Justin Sampson
Printable View
Hi,
Can someone tell me how I hide a layer when someone clicks a link? I used to know how but I forget. :)
Thanks,
Justin Sampson
bru i got quite a large script that does not only hide layers but a load of other cool layer funtions i really think you'll enjoy this
so i'll mail you the whole script rather than post it the example is a bit big.... but you can make it smaller
for yourself
A JavaScript function to hide a layer given its ID is:
The to call this when clicking a link (say you wanted to hide the layer with ID "myLayer"):Code:function hideLayer(layerid) {
if (document.getElementById) {
// DOM-compliant browsers (MSIE5, NSN6, O5)
document.getElementById(layerid).style.visibility='hidden';
} else if (document.all) {
// MSIE4
return document.all[layerid].style.visibility='hidden';
} else if (document.layers) {
// NSN4
return document.layers[layerid].visibility='hidden';
} else {
// Trap DHTML-impaired browsers
//alert("Your browser does not support DHTML!");
return false;
}
}
This code will work in NS4.x, NS6, MSIE 4+, and Opera 5.x.Code:<a href="javascript:hideLayer('myLayer');">...</a>