Get the browser viewport dimensions with JavaScript

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I want to provide my visitors the ability to see images in high quality, is there any way I can detect the window size?

Or better yet, the viewport size of the browser with JavaScript? See green area here:

https://i.stack.imgur.com/zYrB7.jpg https://i.stack.imgur.com/zYrB7.jpg

Answers

http://dev.w3.org/csswg/mediaqueries/#height http://dev.w3.org/csswg/mediaqueries/#height

var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);

window.innerWidth and .innerHeight

document.documentElement.clientWidth and .clientHeight

Resources

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/1248081/get-the-browser-viewport-dimensions-with-javascript

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils