3

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

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

6 Comments

@lauthiamkok well, IE is basically doing it right. Have you considered screen.availWidth?
yes now finally got it right with alert(window.screen.availWidth);
however, it stays at 1280 when you resize your browser window... never mind. thanks :-)
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.
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.
|
1

Use $(document).width()

Comments

1

I had the same problem as you!

I found that using

var height = window.innerHeight || $(window).height();
var width = window.innerWidth || $(window).width();

will give the same value both in chrome and IE

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.