不知道你取得IE窗口的位置与大小有什么用,如果是为了让你的窗口在一个特定的位置上可以这样!
index.htm(其实这一个页面并不会显示)
<HTML>
<HEAD>
<TITLE>首页</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
body {
    margin: 0px;
    padding: 0px;
    border: none;
}
</style>
</HEAD><BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
window.open("test.htm","","top="+((screen.availHeight-(screen.availHeight-100))/2)+",left="+((screen.availWidth-(screen.availWidth-100))/2)+",width="+(screen.availWidth-100)+",height="+(screen.availHeight-100));
try{
    self.focus();
    self.focus();
    window.opener=window.name;
    window.close();
}catch(exception){}
//-->
</SCRIPT>
</BODY>
</HTML>test.htm(是你真正要显示的页面)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Test </TITLE>
</HEAD>
<BODY>
此窗口居中
</BODY>
</HTML>如果只是想要窗口的位置和大小,估计很难!呵呵,可能是我孤陋寡闻吧!

解决方案 »

  1.   

    NS下可以用window.innerWidth,window.innerHeight,window.screenX,window.screenY(window.screenLeft,window.screenTop)IE下没办法,可以用onresize来计算获得,但并不一定就是百分百准确
      

  2.   

    我想实现这样的效果:当用户打开主页(index.htm)时,如果当前窗口较大,则不做任何处理;如果当前窗口较小时,调用window.resizeTo(newwidth,newheight)设置到指定大小并调用window.moveTo(x,y)让它居中。但resizeto是针对IE窗口的,而IE窗口的大小与body的大小无固定关系(工具条、状态条等因素的影响),不知IE窗口的大小,就很难通过resizeto保证客户端的大小,也很难通过moveTo使窗口居中。
      

  3.   

    to fason(阿信):
      window.screenLeft,window.screenTop可以取得窗口的位置,Tks!还是不知如何获取窗口的大小
      

  4.   

    看看这张图。
    http://fason.nease.net/image/dhtmlpos.gif
      

  5.   

    to littleboys(飞龙):
      这些都是基于body或body中的对象的属性。我想要基于当前窗口的属性。tks!
      

  6.   

    var popUpWin=0;
    function popUpWindow(URLStr, left, top, width, height)
    {
      if(popUpWin)
      {
        if(!popUpWin.closed) popUpWin.close();
      }
      popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
    }//URLStr, 打开的链接
    //left,到左边的距离
    //top, 到顶部的距离
    //width,窗口大小
    //height,窗口高
      

  7.   

    <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>