首页 > Web开发 > 详细

用jQuery监听浏览器窗口的变化

时间:2017-10-30 13:20:05      阅读:258      评论:0      收藏:0      [点我收藏+]
1 $(window).resize(function () {          //当浏览器大小变化时
2     alert($(window).height());          //浏览器时下窗口可视区域高度
3     alert($(document).height());        //浏览器时下窗口文档的高度
4     alert($(document.body).height());   //浏览器时下窗口文档body的高度
5     alert($(document.body).outerHeight(true)); //浏览器时下窗口文档body的总高度 包括border padding margin
6 });

 

 1 <script>
 2 function adjust(obj){
 3   var div = document.getElementById("pad");
 4   var txt = document.getElementById("txt");
 5   var w = document.body.clientWidth;
 6   var h = document.body.clientHeight;
 7   div.style.width = w/3;
 8   div.style.height = h/3;
 9   txt.style.width = w/6;
10   txt.style.height = h/6;
11 }
12 window.onload=function(){
13  window.onresize = adjust;
14  adjust();
15 }
16 </script>
17 <body style="margin:0px;height:0px;">
18 <div id="pad" style="background:red;zoom:1;margin:0px;height:0px;">
19   <input type="text" id="txt">
20 </div>
21 </body>

 

用jQuery监听浏览器窗口的变化

原文:http://www.cnblogs.com/ysx215/p/7753891.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!