views:

57

answers:

2

my computer screen width is 1280 but why IE says it's 1259 but other browsers say 1280 with widht();?

$(document).ready(function(){
    alert($(window).width());
});

can it be fixed for IE?? have a look here,

http://ec-ener.eu/dump/index3.php

Thank, Lau

A: 

window.width() doesn't give you the screen's width, but the current window's.

IE will always show a disabled scroll bar to the right of your document, even when it's not needed.

I assume it's that width that gets subtracted in IE.

Try using screen.availWidth to get the full screen width.

Pekka
thanks for the reply. guess there is no way to fix the IE...
lauthiamkok
@lauthiamkok well, IE is basically doing it right. Have you considered `screen.availWidth`?
Pekka
yes now finally got it right with alert(window.screen.availWidth);
lauthiamkok
however, it stays at 1280 when you resize your browser window... never mind. thanks :-)
lauthiamkok
That's why you want `$(window).width()`. That returns the width of the viewport, which is what matters for your web page inside it. How big the *screen* is is almost never of any importance.
bobince
yes you are right - How big the screen is is almost never of any importance. I think I started the OP incorrectly, I should be looking for the width of the document which I still cannot solve it on IE but never I found other way to avoid using the width of the document. thanks.
lauthiamkok
@lauthiamkok IE is correct in showing the width of the document the way it does. It is taking into consideration the space the scroll bar is occupying.
Pekka
A: 

Use $(document).width()

Gaby
thanks. tried it but still the same...:(
lauthiamkok
@lauthiamkok, what version of IE ? it works in IE8
Gaby
IE7... sigh for IE...:-)
lauthiamkok