Jason
Jason

Reputation: 11615

document.width - IE Bug

I am trying to set the width and height of a mask behind a modal window.

I am using $(document).width() and $(document).height().

Works great in FF and Chrome but IE adds about 25px to each and I end up with scroll bars? What am I supposed to use that is cross browser compatible?

I am using IE8 btw, but I want it to work down to 6 or 7.

Upvotes: 3

Views: 1509

Answers (3)

gblazex
gblazex

Reputation: 50109

Just use $(window).width() & $(window).height() (demo).

Upvotes: 6

Jason
Jason

Reputation: 11615

If you are trying to fill up the view-port $(window).width() and $(window).height() is what you want to use. Works in IE.

Upvotes: 1

Spudley
Spudley

Reputation: 168655

Question: Are you using a doctype on your page? It sounds like the kind of glitch you may get if IE goes into quirks mode, which can be avoided if you use a doctype.

If you haven't got one, all you need is a very simple line at the top of your site:

<!DOCTYPE html>

Hope that helps.

Upvotes: 4

Related Questions