sebcreative
sebcreative

Reputation: 29

Why does window.innerWidth returns 477px even if the window has a smaller width?

When I resize the browser window to a lower width than 477px, window.innerWidth or window.getSize().x (using mootools) still returns 477px.

Anyone ever had that problem? What's going on here?

The problem occurs in Firefox and Chrome.

Upvotes: 1

Views: 1726

Answers (3)

AlexThunder
AlexThunder

Reputation: 168

Try document.body.clientWidth.

Upvotes: 0

Dimitar Christoff
Dimitar Christoff

Reputation: 26165

workaround: http://jsfiddle.net/H4snF/1 - window.getCoordinates().width returns fine.

Upvotes: 4

Claudiu
Claudiu

Reputation: 3261

When the code gets called, is the window resized? It might be the case where the call to window.getSize().x gets called before you resize the window. Maybe you should attach the call to an anchor element on your page and only call it after the resize.

Upvotes: 0

Related Questions