我有,通過此鏈接激活一個浮動層:打開和關閉浮動層相同的鏈接?
<a href="javascript:ToggleFloatingLayer('FloatingLayer',1);"> BUTTON </a>
這就是浮動層:
<div id="FloatingLayer">
<div id="closeX"> <a href="#" onClick="ToggleFloatingLayer('FloatingLayer',0);return false">x</a>
</div>
腳本:
<script language="JavaScript1.2">
function ToggleFloatingLayer(DivID, iState) // 1 visible, 0 hidden
{
if(document.layers) //NN4+
{
document.layers[DivID].visibility = iState ? "show" : "hide";
}
else if(document.getElementById) //gecko(NN6) + IE 5+
{
var obj = document.getElementById(DivID);
obj.style.visibility = iState ? "visible" : "hidden";
}
else if(document.all) // IE 4
{
document.all[DivID].style.visibility = iState ? "visible" : "hidden";
}
}
</script>
我想要的 「按鈕」打開並關閉這個浮動層。所以它打開並關閉在同一個鏈接。但現在我只能通過「closeX」x關閉它。我該怎麼做?
使用jQuery它很容易讓你管理跨瀏覽器問題 – 2014-10-18 21:23:15