下面我使用的JavaScript可以在单个onclick函数中正常工作。我同时需要两个onclick函数。在javascript中切换图层
// JavaScript Document
var state = 'hidden';
function showhide(layer_ref) {
if (state == 'visible') {
state = 'hidden';
}
else {
state = 'visible';
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval("document.all." + layer_ref + ".style.visibility = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].visibility = state;
}
if (document.getElementById && !document.all) {
maxwell_smart = document.getElementById(layer_ref);
maxwell_smart.style.visibility = state;
}
}
下面的HTML onclick工作正常。
<a href="#" onclick="showhide('sidebar')" ><img src="supports/images/cp.png" width="86" height="20" /></a>
现在,我需要确切的语法来同时切换两个图层。我尝试使用下面的代码,但它不工作。任何人都可以为我纠正它。
<a href="#" onclick="showhide('sidebar'); showhide('div_menu');" ><img src="supports/images/cp.png" width="86" height="20" /></a>
我没有得到你:-( – Mal