<!DOCTYPE html>
<html>
<head>
<title>请调解浏览器窗口</title>
<meta charset="utf-8" />
<meta http-equiv="content-type" content="text/html; charset=gb2312">
</head>
<body>
<h2 align="center">请调解浏览器窗口大小</h2><hr>
<form action="#" method="get" name="form1" id="form1">
<!--显现浏览器窗口的现实尺寸-->
浏览器窗口 的 现实高度: <input type="text" name="availHeight" size="4"><br>
浏览器窗口 的 现实宽度: <input type="text" name="availWidth" size="4"><br>
</form>
<script type="text/javascript">
var winWidth = 0;
var winHeight = 0;
function findDimensions() //函数:猎取尺寸
{
//猎取窗口宽度
if (window.innerWidth)
winWidth = window.innerWidth;
else if ((document.body) && (document.body.clientWidth))
winWidth = document.body.clientWidth;
//猎取窗口高度
if (window.innerHeight)
winHeight = window.innerHeight;
else if ((document.body) && (document.body.clientHeight))
winHeight = document.body.clientHeight;
//经由过程深切Document内部对body举行检测,猎取窗口大小
if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth)
{
winHeight = document.documentElement.clientHeight;
winWidth = document.documentElement.clientWidth;
}
//效果输出至两个文本框
document.form1.availHeight.value= winHeight;
document.form1.availWidth.value= winWidth;
}
findDimensions();
//挪用函数,猎取数值
window.onresize=findDimensions;
</script>
</body>
</html>
泉源:http://blog.csdn.net/xxtjp/article/details/6948731