js jquery 获取浏览器屏幕宽度高度
每次获取浏览宽度就让自己很头疼,那么多width,到底那个是自己需要的?
http://www.cnblogs.com/cr7/archive/2010/03/17/1688379.html js获取浏览器屏幕高度宽度
http://wanghuiwl320.blog.163.com/blog/static/21598811201101291144465/ jquery获取浏览器屏幕高度宽度
看了一下里面截图,很难受,自己截下图,方便记忆。
window屏幕的高度和宽度 window.screen.height window.screen.width

window工作区高度和宽度 window.screen.availHeight window.screen.availWidth
上面图片去掉类似这样的任务栏就是的。
<html>
<head>
<title>请调整浏览器窗口</title> <meta http-equiv="content-type" content="text/html; charset=gb2312">
</meta>
</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;
document.writeln("屏幕高度 "+window.screen.height);
document.writeln("屏幕宽度"+ window.screen.width);
document.writeln("屏幕可用工作区高度"+ window.screen.availHeight);
document.writeln("屏幕可用工作区宽度"+ window.screen.availWidth);
//-->
</script>
</body>
</html>
正在学习wp7
浙公网安备 33010602011771号