javascript - Get browser width and height after user resizes the window -
is there way browser width , height after user has resized window. example if window 1920 1080 , user changes window 500 500 there way 2 new values in javascript or jquery?
pure javascript answer:
var onresize = function() { //your code here //this example width = document.body.clientwidth; height = document.body.clientheight; } window.addeventlistener("resize", onresize);
this works fine on chrome. however, works on chrome. more cross-browser example using event target properties "outerwidth" , "outerheight", since in case event "target" window itself. code this
var onresize = function(e) { //note need pass event argument function width = e.target.outerwidth; height = e.target.outerheight; } window.addeventlistener("resize", onresize);
this works fine in firefox , chrome
hope helps :)
edit: tested in ie9 , worked :)
Comments
Post a Comment