中国开发网: 论坛: 程序员情感CBD: 贴子 531095
Miracle: 看来还是要自己搞搞。。。。发个测试代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="ProgId" content="VisualStudio.HTML">
<meta name="Originator" content="Microsoft Visual Studio .NET 7.1">
<script language="javascript">
function GetAbsoluteLocationEx(element)
{
if(typeof(element.offsetLeft) != "undefine")
{
var coords = { x: 0, y: 0};
while (element)
{
coords.x += element.offsetLeft;
coords.y += element.offsetTop;
element = element.offsetParent;
}
return coords;
}
else
{
var o = document.getBoxObjectFor(element);

return {x: o.x, y: o.y};
}

return null;

}
function showAxis(element)
{
var o = GetAbsoluteLocationEx(element);
alert(element.id + ": " + o.x + ", " + o.y);
}</script>
</head>
<body>
<div id="div1" style="z-index: 100; background-color: red; width: 100px; height: 100px" onclick="showAxis(this);">1</div>
<div id="div2" style="z-index: 200; background-color: green; width: 100px; height: 100px" onclick="showAxis(this);">2</div>
<div id="Div3" style="position: absolute; top: 100px; left: 400px; z-index: 300; background-color: red; width: 100px; height: 100px" onclick="showAxis(this);">3
<div id="Div4" style="z-index: 400; background-color: green; width: 50px; height: 50px; left: 10px; top; 10px; position: relative" onclick="showAxis(this);">4</div>
</div>

</body>
</html>
夫习拳艺者,对已者十之七八,对人者,仅十之二三耳。拳艺之道,深无止境。得其浅者,一人敌,得其深者,何尝不万人敌耶!
我的Google Picasa相册
我的新BLOG

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录