function findPosition( o )
{
var x2 = 0;
var y2 = 0;
var width = o.offsetLeft;
var height = o.offsetTop;
alert(width + "=" + height);
if( typeof( o.offsetParent ) != 'undefined' )
{
for( var posX = 0, posY = 0;o; o = o.offsetParent )
{
posX += o.offsetLeft;
posY += o.offsetTop;
}
x2 = posX + width;
y2 = posY + height;
return [ posX, posY ,x2, y2]; } else{
x2 = o.x + width;
y2 = o.y + height;
return [o.x, o.y, x2, y2];
}
}
用这个办法返回不了元素的坐标范围,谁能帮我看看??
{
var x2 = 0;
var y2 = 0;
var width = o.offsetLeft;
var height = o.offsetTop;
alert(width + "=" + height);
if( typeof( o.offsetParent ) != 'undefined' )
{
for( var posX = 0, posY = 0;o; o = o.offsetParent )
{
posX += o.offsetLeft;
posY += o.offsetTop;
}
x2 = posX + width;
y2 = posY + height;
return [ posX, posY ,x2, y2]; } else{
x2 = o.x + width;
y2 = o.y + height;
return [o.x, o.y, x2, y2];
}
}
用这个办法返回不了元素的坐标范围,谁能帮我看看??
就是没有参照系啊。要先获取整个屏幕的大小,