views:

177

answers:

2

im using 960 and i want to adjust the nr of columns depending on the user's screen size.

how do javascript/jquery get the resolution of the screen?

+1  A: 

screen.width will tell you the screens width. Or maybe screen.availWidth would be better. Note also that with jQuery you can get the $.width() and $.height() of items: $(window).width() for instance will tell you how wide your window is.

Jonathan Sampson
what is the difference between width and availwidth?
weng
`availWidth` excludes scrollbars, etc.
Jonathan Sampson
+2  A: 

I would argue that screen size doesn't matter. What matters is how wide their viewport for your page is. They could have a 3000px across screen, but be viewing your page with only 1000px wide browser window.

In jQuery you can get the viewport width like this:

 $(window).width()
Doug Neiner
+1 Good point with the window.
Jonathan Sampson
+1 Indeed. A very good point. I too think he is asking the wrong question.
Edelcom