zoukankan      html  css  js  c++  java
  • 一天JavaScript示例-判定web页面的区域

    <!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,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>
    

    版权声明:本文博主原创文章。博客,未经同意不得转载。

  • 相关阅读:
    1755:菲波那契数列
    1788:Pell数列
    3089:爬楼梯
    7832:最接近的分数
    7649:我家的门牌号
    7216:Minecraft
    7213:垃圾炸弹
    2983:谁是你的潜在朋友
    2723:因子问题
    2722:和数
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/4904991.html
Copyright © 2011-2022 走看看