Welcome to WebmasterWorld Guest from 54.161.116.225

Forum Moderators: open

Message Too Old, No Replies

Checking for screen resolution on the secondary screen?

How to?

     
1:32 pm on Jun 18, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:June 15, 2007
posts:86
votes: 0


I am trying to get the screen resolution from the user computer and so far the scrpt below seems fine

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.

Regards

NooK

2:17 pm on June 18, 2008 (gmt 0)

Full Member

10+ Year Member

joined:Sept 5, 2007
posts:264
votes: 0


Darned good question. It's an issue that's occurred to me but I've never tested for it but now I am. If I can get to it quickly, I'll let you know what I find out.

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.

9:35 am on June 19, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:June 15, 2007
posts:86
votes: 0


Yeah I'd imagine that browser should return the resolution on the screen the browser is currently on but it doesn't seem to be the case. :(

Give me a shout if you come up with anything because so far googling hasn't gotten me anywhere and I can't anything on the javascript API that even mentions specific screen properties.

2:34 pm on June 19, 2008 (gmt 0)

Full Member

10+ Year Member

joined:Sept 5, 2007
posts:264
votes: 0


Based on my own very unscientific and very narrow test using my main laptop and external screen - giving me two screens to play around with. Here's what I think:

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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members