日期:2014-05-16  浏览次数:20431 次

pixelTop为何针对页内样式0
JScript code
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档 </title>
<Script language="javascript">
var advInitTop=0;  //广告的初始顶为0;
function inix()
{
x=document.getElementById("adv2").style.pixelTop;
alert(x);
}
</Script>
<style>
div#adv2{position:absolute;left:662px;top:210px;width:185px;height:233px;z-index:2;}
</style>
</head>

<body onload="inix()">
<div id=aaa style="LEFT: 10px; POSITION: absolute; TOP: 10px; height:20px">测试 </div>

<div id="adv2">
<img src="images/b_C6DB56D418E332EDE7F138C00A4DC7D4.jpg" width="185" height="231">
</div>
</body>
</html>


如果针对div行内写的style,则可以显示为具体的值,和top一致。而如果设置为业内样式,则显示pixelTop为0
????

------解决方案--------------------
看看手册就都明白了

DHTML参考手册.rar
http://download.csdn.net/source/308913