Last active
May 11, 2017 16:44
-
-
Save jtechera/8b22f1adea98f563cdc8eeca6c994c9b to your computer and use it in GitHub Desktop.
Browser / Screen / Document width and height
From http://stackoverflow.com/questions/3437786/get-the-size-of-the-screen-current-web-page-and-browser-window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*If you are using jQuery, you can get the size of the window or the document using jQuery methods:*/ | |
$(window).height(); // returns height of browser viewport | |
$(document).height(); // returns height of HTML document (same as pageHeight in screenshot) | |
$(window).width(); // returns width of browser viewport | |
$(document).width(); // returns width of HTML document (same as pageWidth in screenshot) | |
/*For screen size you can use the screen object in the following way:*/ | |
screen.height; | |
screen.width; | |
/* Wihout jQuery */ | |
var width = window.innerWidth | |
|| document.documentElement.clientWidth | |
|| document.body.clientWidth; | |
var height = window.innerHeight | |
|| document.documentElement.clientHeight | |
|| document.body.clientHeight; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment