Last active
March 31, 2017 09:50
-
-
Save bogdanpopa90/681c3658d18a53556172398d405356e3 to your computer and use it in GitHub Desktop.
Get window width depending on the browser with JavaScript
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 ( getWidth() >= 992 ) { | |
// do something | |
} | |
/* Get window width depending on the browser with JavaScript */ | |
function getWidth() { | |
if (this.innerWidth) { | |
return this.innerWidth; | |
} | |
if (document.documentElement && document.documentElement.clientWidth) { | |
return document.documentElement.clientWidth; | |
} | |
if (document.body) { | |
return document.body.clientWidth; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment