Home > Web Front-end > JS Tutorial > JS and jquery code to obtain the width and height of various screens_Basic knowledge

JS and jquery code to obtain the width and height of various screens_Basic knowledge

WBOY
Release: 2016-05-16 17:27:13
Original
810 people have browsed it

Javascript:
The width of the visible area of ​​the web page: document.body.clientWidth
The height of the visible area of ​​the web page: document.body.clientHeight
The width of the visible area of ​​the web page: document.body.offsetWidth (including the width of the edge)
The height of the visible area of ​​the web page: document.body.offsetHeight (including the height of the edge)
The full text width of the web page body: document.body.scrollWidth
The full text height of the web page body: document.body.scrollHeight
The web page is scrolled High: document.body.scrollTop
The left side of the web page being scrolled: document.body.scrollLeft
The main body of the web page: window.screenTop
The left side of the main body of the web page: window.screenLeft
Screen resolution The height of the screen: window.screen.height
The width of the screen resolution: window.screen.width
The height of the available work area of ​​the screen: window.screen.availHeight
The width of the available work area of ​​the screen: window.screen.availWidth
JQuery:

Copy code The code is as follows:

$(document).ready( function(){
 alert($(window).height()); //The height of the visible area of ​​the current window of the browser
 alert($(document).height()); //The current window of the browser The height of the document
alert($(document.body).height());//The height of the document body in the current window of the browser
alert($(document.body).outerHeight(true));// The total height of the document body of the current browser window includes border padding margin
 alert($(window).width()); //Width of the visible area of ​​the current browser window
alert($(document).width( ));//The width of the document object in the current window of the browser
alert($(document.body).width());//The width of the document body in the current window of the browser
alert($(document.body) .outerWidth(true));//The total width of the document body of the current browser window includes border padding margin
 })
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template