在onload里面执行:
<SCRIPT LANGUAGE="JavaScript">
<!--
function fnInit()
{
var abc = document.getElementById("a");
abc.style.display = "";
}
//-->
</script>
</head><body onload="fnInit()"><div id="a" style="display:none">asdf</div></body></html>
<SCRIPT LANGUAGE="JavaScript">
<!--
function fnInit()
{
var abc = document.getElementById("a");
abc.style.display = "";
}
//-->
</script>
</head><body onload="fnInit()"><div id="a" style="display:none">asdf</div></body></html>
document.all.a.style.display = "";
</script>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title></head><body><div id="a" style="display:none">asdf</div></body></html>
<SCRIPT LANGUAGE="JavaScript">
<!--
var abc = document.getElementById("a");
abc.style.display = "";
//-->
</script>
就对了
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title></head><body><div id="a" style="display:none">asdf</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
var abc = document.getElementById("a");
abc.style.display = "";
//-->
</script></body></html>------------------------------
同志,你要讲究先来后到的次序啊,呵呵,或者把代码放在window.onload事件时执行,也不会有问题。window.onload=function(){
var abc = document.getElementById("a");
abc.style.display = "";
}