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:
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
Post a Comment