markzzz
markzzz

Reputation: 47945

JQuery - Document width/height - Different values from different browsers

var maskWidth = $(window).width();
alert(maskWidth);

I get 1263 from chrome and firefox (which is 1280 in fact, but with scroll it write a less value). IE print 1259.

How can I fix this problems with JQuery?

Upvotes: 2

Views: 2057

Answers (2)

Mohan Ram
Mohan Ram

Reputation: 8463

$.clientCoords = function(){
    if(jQuery.browser.msie){
        return {
            w:document.documentElement.offsetWidth,
            h:document.documentElement.offsetHeight
        }
    }
    else
        return {w:window.innerWidth, h:window.innerHeight}
}

This function returns the height and weight of browser or current window

Upvotes: 1

Greg
Greg

Reputation: 21899

This isn't a problem with jQuery, it is returning the value of the displayable portion of your website.

You need to be looking at .innerWidth() here which will return results closer to which you require.

Upvotes: 4

Related Questions