x=obj.offsetLeft;
y=obj.offsetTop;
objParent=obj.offsetParent;
while(objParent.tagName.toUpperCase()!= "BODY"){
x+=objParent.offsetLeft;
y+=objParent.offsetTop;
objParent = objParent.offsetParent;
}
这样根据x,y就可以绝对定位

解决方案 »

  1.   

    楼上的说得 obj 就是你的层的id  objParent大约就是说的你的层所在的document offsetLeft和offsetTop就是相对的偏移量
      

  2.   

    用Macromedia Dreamweaver MX的timeline做一個動畫,再好好看自動生成的代碼
      

  3.   

    <body>
    <div id="testLayer"></div>
    <script>
    alert(getLayer(testLayer));
    function getLayer(obj)
      x=obj.offsetLeft;
      y=obj.offsetTop;
      objParent=obj.offsetParent;
      while(objParent.tagName.toUpperCase()!= "BODY"){
        x+=objParent.offsetLeft;
        y+=objParent.offsetTop;
        objParent = objParent.offsetParent;
      }
      return [x,y]
    }
    </script>
    </body>
      

  4.   

    chenzengxi(懒猫):
    谢谢,我把你的代码拷贝到dw里为什么不好使啊,我用的是dw4.0