This is quick article related to JavaScript we will see how we can get browser viewport size using Core JavaScript, MooTools and jQuery.
Core JavaScript
[cc lang=”javascript”]
// Get Browser Viewport Width
var width = window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth;
// Get Browser Viewport Height
var height = window.innerHeight ||
document.documentElement.clientHeight ||
document.body.clientHeight;
[/cc]
jQuery
[cc lang=”javascript”]
// Get Browser Viewport Width
var width = $(window).width();
// Get Browser Viewport Height
var height = $(window).height();
[/cc]
MooTools
[cc lang=”javascript”]
// Get Browser Viewport Width
var width = window.getSize().x;
// Get Browser Viewport Height
var height = window.getSize().y;
[/cc]
Hope you find this quick tip helpful, Also consider sharing the same thing for other JavaScript frameworks.