您的位置:首页 > Web前端 > JavaScript

js获取table中td的绝对坐标

2006-12-18 17:51 253 查看
我的免费电影网站一:http://www.foxwow.com

我的免费电影网站二:http://www.91free.org

方法1:

function getAbsPoint(e)

{

var x = e.offsetLeft, y = e.offsetTop;

while(e=e.offsetParent)

{

x += e.offsetLeft;

y += e.offsetTop;

}

alert("x:"+x+","+"y:"+y);

}

方法2:

function getAbsPoint(obj)

{

var x,y;

oRect = obj.getBoundingClientRect();

x=oRect.left

y=oRect.top

alert("("+x+","+y+")")

}

JS中获得窗口属性的方法

1。获得屏幕的分辨率:

screen.width

screen.height

2。获得窗口大小:

document.body.clientWidth

document.body.clientHeight

3。获得窗口大小(包含Border、Scroll等元素)

document.body.offsetWidth

document.body.offsetHeight

http://p.blog.csdn.net/images/p_blog_csdn_net/yicel/263904/o_08_193405_b91edhtmlpos.gif" border="0" >
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: