1

I use the javascript property screen.width to know which CSS to use... But with Internet explorer (both 7 and 8, I didn't tried on 9), the returned value is the one of my main screen (which is not the one I use...).

Does anyone have a solution ? Maybe another property ? (I also tried with screen.availWidth, it didn't worked)

Nicolas

Nicolas
  • 1,812
  • 3
  • 19
  • 43
  • doesn't sound like a good solution, what if the user drags the window to the other screen after the page is loaded? 1 CSS should cover both cases. – roberkules Jun 15 '11 at 10:25
  • Actually, the site is currently optimized for 1280px... But for marketing purposes, I have to "make it work" for 1024px... When you say "1 CSS should cover both cases.", do you mean "the display has to be the same whatever the resolution" or "the CSS has to adapt automatically the display" ? – Nicolas Jun 15 '11 at 12:04
  • I prefer the website to be fluid. One possible solution would be something like http://tjkdesign.com/articles/css-layout/no_div_no_float_no_clear_no_hack_no_joke.asp -> check the "Fluid (min/max)" link in the left sidebar. – roberkules Jun 15 '11 at 12:34

1 Answers1

1

Maybe you could use the window.innerWidth property? Only downside is, it looks at the window, not the screen, which may not be what you want..

Thor Jacobsen
  • 8,621
  • 2
  • 27
  • 26
  • It doesn't work on IE (document.body.offsetWidth does, I may gonna try it) – Nicolas Jun 15 '11 at 12:02
  • That's actually another good point. @Nicolas: you are forcing the user to maximize the browser window. But what if he has a big screen, but the browser window has only the size of around 1024x768? – roberkules Jun 15 '11 at 12:36
  • Well... good points : so I'm gonna set the display to 1024px for all resolutions. – Nicolas Jun 15 '11 at 12:57
  • see also http://stackoverflow.com/questions/1413602/are-fluid-websites-worth-making-anymore – roberkules Jun 15 '11 at 14:35