jquery width() and height() functions are consistently returning the wrong values for the viewport size (i.e. $(window).width). Anyone know why…or what I can do to fix it?
thanks.
jquery width() and height() functions are consistently returning the wrong values for the viewport size (i.e. $(window).width). Anyone know why…or what I can do to fix it?
thanks.
Seems IE has a different way of calculating the viewport width and height, i would simply do the following so IE in IE the correct width is still set
var viewPortWidth;
var viewPortHeight;
$.each($.browser, function(i){
if ($.browser.msie){
viewPortWidth = $.width()+4;
viewPortHeight = $.height()+2;
} else {
viewPortWidth = $.width();
viewPortHeight = $.height();
}
});
That’s just how i would do it but someone else might have something better
No need for $.each
var viewPortWidth;
var viewPortHeight;
if ($.browser.msie){
viewPortWidth = $.width()+4;
viewPortHeight = $.height()+2;
} else {
viewPortWidth = $.width();
viewPortHeight = $.height();
}
Works perfectly. Thanks guys.