当前位置:网站首页>JS to get the browser and screen height

JS to get the browser and screen height

2022-04-23 21:23:00 Sister Chunfeng

Javascript:

IE in :
document.body.clientWidth ==> BODY Object width 
document.body.clientHeight ==> BODY Object height 
document.documentElement.clientWidth ==>  The width of the visible area 
document.documentElement.clientHeight ==>  Height of visible area 
FireFox in :
document.body.clientWidth ==> BODY Object width 
document.body.clientHeight ==> BODY Object height 
document.documentElement.clientWidth ==>  The width of the visible area 
document.documentElement.clientHeight ==>  Height of visible area 
Opera in :
document.body.clientWidth ==>  The width of the visible area 
document.body.clientHeight ==>  Height of visible area 
document.documentElement.clientWidth ==>  Page object width ( namely BODY Object width plus Margin wide )
document.documentElement.clientHeight ==>  Page object height ( namely BODY Object height plus Margin high )

alert(document.body.clientWidth);        // Page visible area width (body)

alert(document.body.clientHeight);       // Page visible area high (body)

alert(document.body.offsetWidth);       // Page visible area width (body), Include border、margin etc. 

alert(document.body.offsetHeight);      // Page visible area width (body), Include border、margin etc. 

alert(document.body.scrollWidth);        // Full text width of web page body , Include the unseen area with scroll bar 

alert(document.body.scrollHeight);       // Page body full text height , Include the unseen area with scroll bar 

alert(document.body.scrollTop);           // Web pages are rolled away Top( Scroll bar )

alert(document.body.scrollLeft);           // Web pages are rolled away Left( Scroll bar )

alert(window.screenTop);                     // Browser distance Top

alert(window.screenLeft);                     // Browser distance Left

alert(window.screen.height);                // High screen resolution 

alert(window.screen.width);                 // Width of screen resolution 

alert(window.screen.availHeight);          // The height of the screen's usable workspace 

alert(window.screen.availWidth);           // The width of the screen's usable workspace 

Jquery

alert($(window).height());                           // The height of the viewable area of the browser's current window 

alert($(document).height());                        // The height of the browser's current window document 

alert($(document.body).height());                // Browser current window document body Height 

alert($(document.body).outerHeight(true));  // Browser current window document body The total height of   Include border padding margin

alert($(window).width());                            // The width of the viewable area of the browser's current window 

alert($(document).width());                        // Browser current window document object width 

alert($(document.body).width());                // Browser current window document body Width 

alert($(document.body).outerWidth(true));  // Browser current window document body Total width of   Include border padding margin

版权声明
本文为[Sister Chunfeng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/110/202204200620164144.html