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 margin6 });
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