不知道你取得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>如果只是想要窗口的位置和大小,估计很难!呵呵,可能是我孤陋寡闻吧!
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>如果只是想要窗口的位置和大小,估计很难!呵呵,可能是我孤陋寡闻吧!
解决方案 »
- jquery的$(window).resize()怎么用原生JS实现?
- 前面是谁想操作表单列的?找不着原帖了,只好发帖回复你一个不成熟的demo。
- 请问淘宝商城左边的商品分类功能如何实现。谢谢
- JSTL库 foreach问题
- loadJS
- 关于Unicode编码与解码问题
- 帮忙解释一下,下面javascript的含义
- js定时器断线重连,
- easyui datagrid中某列设置editor类型为combobox,combobox如何动态加载json数据,而且每一行的数据不一样
- 谁有交换图片的源代码?
- 如何将javascript中的数组值传给jsp?
- 在JS中有没有办法把window.open打开的窗口句柄作为全局变量保存下来,留到以后reload()做刷新操作?
window.screenLeft,window.screenTop可以取得窗口的位置,Tks!还是不知如何获取窗口的大小
http://fason.nease.net/image/dhtmlpos.gif
这些都是基于body或body中的对象的属性。我想要基于当前窗口的属性。tks!
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,窗口高
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>