DIV隐藏的时候用 visibility = "hidden"; 不要使用 display = "none";
<html lang="utf-8" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<script language="JavaScript">
function $(id){
return (document.getElementById(id));
}
window.onload = function(){
var o = $("subnav5");
alert(o.offsetHeight);
}
</script>
<body>
<li>
<a href="#" id="nav_5" onmouseover="showMenu('nav_5','subnav5')">网络编程</a>
<div class="subnav disable" id="subnav5" style="overflox:auto;position:absolute;visibility:hidden;">
<p class="pointer">
.
</p>
<p>
<span><a href="#">Asp编程</a> |<a href="#">Php编程</a> |<a href="#">.Net编程</a> |<a href="#">Xml编程</a> |<a href="#">Access</a> |<a href="#">Mssql</a> |<a href="#">Mysql</a></span>
</p>
</div>
<br>
Hello World!
</li>
</body>
</html>
<html lang="utf-8" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<script language="JavaScript">
function $(id){
return (document.getElementById(id));
}
window.onload = function(){
var o = $("subnav5");
alert(o.offsetHeight);
}
</script>
<body>
<li>
<a href="#" id="nav_5" onmouseover="showMenu('nav_5','subnav5')">网络编程</a>
<div class="subnav disable" id="subnav5" style="overflox:auto;position:absolute;visibility:hidden;">
<p class="pointer">
.
</p>
<p>
<span><a href="#">Asp编程</a> |<a href="#">Php编程</a> |<a href="#">.Net编程</a> |<a href="#">Xml编程</a> |<a href="#">Access</a> |<a href="#">Mssql</a> |<a href="#">Mysql</a></span>
</p>
</div>
<br>
Hello World!
</li>
</body>
</html>
ls代码,估计能解决问题。3Q...
和前者等同的效果是 $("subnav5").getElementsByTagName("p")[0].style.left = 60 + "px";
有一个前题,style.position="absolute";。marginLeft是容器左侧空白的宽度。对了,我前面的代码中overflox:auto;这句没用,并且写错了,把它删掉吧。