Jquery獲取當前螢幕的寬度、高度
阿新 • • 發佈:2019-01-23
<script type="text/javascript"> $(document).ready(function() { alert($(window).height()); //瀏覽器當前視窗可視區域高度 alert($(document).height()); //瀏覽器當前視窗文件的高度 alert($(document.body).height());//瀏覽器當前視窗文件body的高度 alert($(document.body).outerHeight(true));//瀏覽器當前視窗文件body的總高度 包括border padding margin alert($(window).width()); //瀏覽器當前視窗可視區域寬度 alert($(document).width());//瀏覽器當前視窗文件物件寬度 alert($(document.body).width());//瀏覽器當前視窗文件body的高度 alert($(document.body).outerWidth(true));//瀏覽器當前視窗文件body的總寬度 包括border padding margin } ) </script>
其中$(window).height( )=$(document).height( )=$(document.body).outerHeight( )=$(document.body).height( )+padding+margin+border