ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Cross-Browser Layers: Part 2
Subject:   Huh?
Date:   2001-08-16 15:19:30
From:   johnq
Why would you use:
onMouseOver='hide();


...with:


function hide() {
if (W3C) {
document.getElementById('layer1').style.visibility = "hidden";
document.getElementById('layer2').style.visibility = "hidden";
document.getElementById('layer3').style.visibility = "hidden";
document.getElementById('layer4').style.visibility = "hidden";
}
else if (IE4) {
document.all['layer1'].style.visibility = "hidden";
document.all['layer2'].style.visibility = "hidden";
document.all['layer3'].style.visibility = "hidden";
document.all['layer4'].style.visibility = "hidden";
}
else if(NN4) {
document.layers['layer1'].visibility = "hidden";
document.layers['layer2'].visibility = "hidden";
document.layers['layer3'].visibility = "hidden";
document.layers['layer4'].visibility = "hidden";
}
}



...ad nauseum when you could just do:



function hide(layerName) {
if (W3C) {
document.getElementById(layerName).style.visibility = "hidden";
}
else if (IE4) {
document.all[layerName].style.visibility = "hidden";
}
else if(NN4) {
document.layers[layerName].visibility = "hidden";
}
}


...and call it with:
onMouseOver='hide("layer1");


...etc.......???


That's what functions are for. :)


1 to 1 of 1
  1. Huh?
    2001-08-16 16:02:10  johnq [View]

    • STYLE / POSITION
      2005-07-25 00:49:55  Dr_Fre [View]

1 to 1 of 1