jQuery 获取屏幕高度和宽度

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<script type="text/javascript" src="jquery-1.10.1.min.js"></script>
</head>
<body>
<script type="text/javascript">
//做手机Web开发做浏览器兼容用到了,所以在网上找了些汇总下。 

document.writeln($(window).height()+"//浏览器当前窗口可视区域高度<br>");

document.writeln($(document).height()+"//浏览器当前窗口文档的高度<br>"); 

document.writeln($(document.body).height()+"//浏览器当前窗口文档body的高度<br>");  

document.writeln($(document.body).outerHeight(true)+"//浏览器当前窗口文档body的总高度 包括border padding margin<br>"); 

document.writeln($(window).width()+"//浏览器当前窗口可视区域宽度<br>"); 

document.writeln($(document).width()+"//浏览器当前窗口文档对象宽度<br>");  

document.writeln($(document.body).width()+"//浏览器当前窗口文档body的高度<br>");  

document.writeln($(document.body).outerWidth(true)+"//浏览器当前窗口文档body的总宽度 包括border padding margin<br>");  
</script>
</body>
</html>

效果图:

 

猜你喜欢

转载自onestopweb.iteye.com/blog/2258477