<style type="text/css">
#main{text-align:center; background-color:#9FF; height:600px;width:800px}
#adver{
position:absolute;
left:50px;
top:30px;
z-index:2;
}
</style>
<script src="js/scroll.js"></script>
</head>
<body>
<div id="adver"><img src="images/adv.jpg"/></div>
<div id="testDiv" style="position:absolute;left:300px;top:50px;background-color:red; width:80px; height:200px">内部样式的div</div>
<input type="button" value="测试内部样式坐标位置" onClick="test('testDiv')"/>
<input type="button" value="测试外部样式坐标位置" onClick="test('adver')"/>
<div id="main">网页内容</div>
</body>
function test (divID){
var divObj=document.getElementById(divID);
alert("left="+divObj.style.left+"\ntop="+divObj.style.top); //只能读取style属性设置的值,不能读取其他如:内部样式、外部样式的值
divObj.style.left=parseInt(divObj.style.left)+200+"px";
divObj.style.top=parseInt(divObj.style.top)+100+"px";
}