jQuery window width sometimes return wrong value -


sometimes when call:

$(window).width(); 

the value returned wrong (on browsers except ie, on ie correct). use line:

$('div.container p').text($(window).width()); 

to change text of p element see value returned when resizing window. here example when value returned wrong: http://prntscr.com/7biu4y

in top right corner, can see actual dimensions on chrome.

i noticed when value wrong, off 17px.

note value returned not wrong of times window looks should.

help!

@inacio schweller correct.

to consistent cross-browser result, can use non-jquery version:

window.innerwidth

try typing console of browser , you'll see returns consistent result regardless of browser using.

note: non-jquery version window.outerwidth returns same result in ie , chrome, returns smaller value in firefox.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -