//取得控件得绝对位置(1)
<script language="javascript"> 
function getoffset(e)

var t=e.offsetTop; 
var l=e.offsetLeft; 
while(e=e.offsetParent)

t+=e.offsetTop; 
l+=e.offsetLeft; 

var rec = new Array(1);
rec[0]  = t;
rec[1] = l; return rec
} //获得控件的绝对位置(2)
oRect = obj.getBoundingClientRect();
oRect.left
oRect.top

解决方案 »

  1.   

    老大,这个是网页上的绝对位置我要屏幕上的绝对位置popup是根据屏幕位置来定位的
      

  2.   

    取网页绝对位置的我这里有一个,贡献出来
    ============================
    function Rect(){
    this.width=0;
    this.height=0;
    this.left=0;
    this.top=0;
    this.right=0;
    this.bottom=0;
    }
    Rect.prototype.Cal=function () {
    this.right=this.left+this.width;
    this.bottom=this.top+this.height;
    }
    Rect.prototype.ContaintPoint=function (x,y){
    if(x>=this.left && x<=this.right && y>=this.top && y<=this.bottom) return true;
    return false;
    }
    Rect.prototype.BeCoverBy=function (rectSrc){
    return rectSrc.ContaintPoint(this.left,this.top) ||
    rectSrc.ContaintPoint(this.left,this.bottom) ||
    rectSrc.ContaintPoint(this.right,this.top) ||
    rectSrc.ContaintPoint(this.right,this.bottom) ||
    this.ContaintPoint(rectSrc.left,rectSrc.top) ||
    this.ContaintPoint(rectSrc.right,rectSrc.top) ||
    this.ContaintPoint(rectSrc.left,rectSrc.bottom) ||
    this.ContaintPoint(rectSrc.right,rectSrc.bottom);
    }
    function getElementRect(obj){
    var e=obj;
    var pos=new Rect;
    pos.width=obj.offsetWidth;
    pos.height=obj.offsetHeight;
    pos.left=obj.offsetLeft;
    pos.top=obj.offsetTop;
    while(e=e.offsetParent){
    pos.left+=e.offsetLeft;
    pos.top+=e.offsetTop;
    }
    pos.Cal();
    return pos;
    }
      

  3.   

    screenLeft 获取浏览器客户区左上角相对于屏幕左上角的 x 坐标。 
    screenTop 获取浏览器客户区左上角相对于屏幕左上角的 y 坐标。 
    这个?
      

  4.   

    …………
    好像是这个
    可是<a href="JavaScript:alert(this.screenLeft);">测试</a>怎么是0?ttyp 知道怎么取得屏幕坐标吗?
      

  5.   

    window.screenLeft
    window.screenTop再加上它的相对位置
      

  6.   

    PS:
    刚才一个朋友理解错了
    偶说的popup是window.createPopup…………faint,是偶的错,没说明白
      

  7.   

    http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/popup.asp
    popup Object 没有位置相关属性和方法。只有在SHOW时确定它的位置。
      

  8.   

    …………
    这个偶知道D就是…………偶想在一个连接旁边显示这个popup object
    popup object的定位方式是全屏幕定位链接的定位方式是网页定位……这两个怎么转换?
      

  9.   

    还没解决?screenLeft,screenTop加上一楼贴的就是了
      

  10.   

    不行啊
    screenLeft,screenTop是window对象的加上工具栏,菜单烂这些就不对了fason,帮帮忙
    ============================谢谢heyixiang,希望能顶个答案出来
      

  11.   

    是的呀,我现在要把popUp出来的这个Window定位在当前网页的某个元素旁边
    怎么定位呀?无法计算当前元素的屏幕位置啊