In all recent browser:
window.innerWidth // 1920
In Internet explorer 8
window.innerWidth // undefined
What is the best way to get this value in IE8?
The innerWidth
is supported by IE9 not IE8, you can do this insteaad:
var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
The above line will get you the width from IE as well as other standard-compliant browsers.
If you use jQuery, $(window).innerWidth()
will give you desired result in all browsers too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With