<body><script>
var strInfo="";
strInfo+="\r\n网页可见区域宽:"+document.body.clientWidth;
strInfo+="\r\n网页可见区域高:"+document.body.clientHeight;
strInfo+="\r\n网页可见区域宽:"+document.body.offsetWidth+"(包括边线的宽)";
strInfo+="\r\n网页可见区域高:"+document.body.offsetHeight+"(包括边线的宽)";
strInfo+="\r\n网页正文全文宽:"+document.body.scrollWidth;
strInfo+="\r\n网页正文全文高:"+document.body.scrollHeight;
strInfo+="\r\n网页被卷去的高:"+document.body.scrollTop;
strInfo+="\r\n网页被卷去的左:"+document.body.scrollLeft;
strInfo+="\r\n网页正文部分上:"+window.screenTop;
strInfo+="\r\n网页正文部分左:"+window.screenLeft;
strInfo+="\r\n屏幕分辨率的高:"+window.screen.height;
strInfo+="\r\n屏幕分辨率的宽:"+window.screen.width;
strInfo+="\r\n屏幕可用工作区高度:"+window.screen.availHeight;
strInfo+="\r\n屏幕可用工作区宽度:"+window.screen.availWidth;
window.confirm(strInfo);
</script>

解决方案 »

  1.   

    function GetDefineX(ObjectID)
    {
    var iPositionX=ObjectID.offsetLeft;
    while(ObjectID=ObjectID.offsetParent)
    {
    iPositionX+=ObjectID.offsetLeft;
    }
    return iPositionX;
    }
    function GetDefineY(ObjectID)
    {
    var iPositionY=ObjectID.offsetTop;
    while(ObjectID=ObjectID.offsetParent)
    {
        iPositionY+=ObjectID.offsetTop;
    }
    return iPositionY;
    }
      

  2.   

    <table><tr><td>
    <span id=MySpan>dddddddddddddddddd<img src="http://community.csdn.net/images/csdn.gif" id=MyImage></span>
    </td></tr></table><script>
    function getDim(el){
    for (var lx=0,ly=0;el!=null;
    lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
    return {x:lx,y:ly}
    }
    mySpanDim = getDim(document.getElementById("MySpan"))
    alert("x:" + mySpanDim.x + ", y:" + mySpanDim.y)myImgDim = getDim(document.images.MyImage)
    alert("x:" + myImgDim.x + ", y:" + myImgDim.y)</script>
      

  3.   

    谢谢大家的热心解答
    我刚刚从旧帖里找到了
    (我要的是相对于屏幕坐标)
    <body style="margin:10;">
    <table cellspacing=10 border=0 cellpadding=0>
    <tr>
    <td>
    <img height=100 width=100>
    <input type=button value=xxx id=sss onclick=test()><br>
    <br>
    </td>
    </tr>
    </table>
    <script language="javascript">
    <!--
    function getAbsPosition(obj)
    {
    var abs={x:0,y:0}
    while(obj!=document.body){
    abs.x+=obj.offsetLeft;
    abs.y+=obj.offsetTop;
    obj=obj.offsetParent;
    }
    return abs;
    }
    function test(){
    x=(window.screenLeft+document.body.clientLeft+getAbsPosition(sss).x-document.body.scrollLeft);
    y=(window.screenTop+document.body.clientTop+getAbsPosition(sss).y-document.body.scrollTop);
    showModalDialog("about:blank", "dd日mm月yyyy年" ,"dialogWidth:286px;dialogHeight:221px;dialogTop:"+y+"px;dialogLeft:"+x+"px;status:no;help:no;");
    }
    //-->
    </script>