Welcome to WebmasterWorld Guest from 18.104.22.168
Forum Moderators: open
alert("You screen width is "+window.screen.width+"\nYou screen height is "+window.screen.height);
The problem is that recently I had a user, run the script on a computer that has 2 screens.
He opened a browser window on the main screen, which yelled the correct resolution, he then moved the browser window to the secondary screen and refreshed the page. The secondary screen is running a lower resolution yet the script still says that it has the primary screens resolution.
Is there any way to get the proper screen resolution?
The problem is that I change the CSS file depending on the user resolution and that kinda breaks the system.
My guess, right now, is that one of the screens is designated in some way as "primary" to use your word. And, of necessity - since the browser can't return two values for the same property - that's the screen used to report screen.width/height.
The operating system designates one screen as Primary. (In the graphics properties box - an NVIDIA driver and accompanying utilities - there is actually a graphic representation of both screens with a big "1" on one of them and a "2" on the other.)
All window.screen properties return values based on the Primary screen. The secondary screen is treated as an extension, a "silent partner" to the primary.
My instincts tell me that it just HAS to be this way. Can you imagine the confusion if it didn't? How would it handle pop-up windows? The mind starts boggling very fast.
And, yeah, my search didn't find much of any value, either.