码迷,mamicode.com
首页 > 编程语言 > 详细

每天一个JavaScript实例-确定web页面的区域

时间:2014-10-23 19:19:10      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   java   div   2014   on   log   

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>每天一个JavaScript实例-确定web页面的区域</title>
<script>
function size(){
	var width = 0;
	var height = 0;
	if(!window.innerWidth){
		width = (document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body.clientWidth);
		height = (document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body.clientHeight);
	}else{
		width = window.innerWidth;
		height = window.innerHeight;
	}
	return {width:width,height:height};
}
window.onload = function(){
	var viewPort = size();
	var w = viewPort.width;
	var h = viewPort.height;
	console.log(w);
	console.log(h);
}
</script>
</head>

<body>

<div id = "date">
</div>

</body>
</html>

每天一个JavaScript实例-确定web页面的区域

标签:blog   http   io   ar   java   div   2014   on   log   

原文地址:http://blog.csdn.net/waiting7436/article/details/40401977

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!