/    Sign up×
Community /Pin to ProfileBookmark

Detection of Multiple Monitors

I’m a bit of a Javascript newb here, so I’d appreciate any help I could get.

What I’m trying to do is this: The website I’m working on has numerous pop-up windows that are often open all at once and as such specifically placed around the screen by the user. Now I’m trying to implement a feature where the positions of each window are saved upon closing in a database and are used when the window is next opened.

But I’ve run into this problem regarding users with multiple monitors. Yes, I can open a window at (1200,0), thus placing it on the user’s second monitor. But what if (s)he unplugs the second monitor before returning? Then the pop-up appears well off the screen (assuming a 1024×768 resolution). Is there someway I can detect whether the point (1200,0) is a valid location on a screen, so I can revert the pop-up window’s location to some sort of default if it isn’t?

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@96turnerriFeb 03.2004 — you could use screen.width or screen.height and use an if statement

if (screen.width <= 1024) {

popup ones locations blah blah

}
Copy linkTweet thisAlerts:
@blawauthorFeb 03.2004 — I'm sorry, but I'm not sure I understand your solution. Based on my test with several computers here in the office that have multiple monitors (2-4), screen.width always simply returns the width of the screen in which the Internet Explorer window is placed. Like, on a computer with two monitors at 1024, screen.width will always return 1024, never 2048.
Copy linkTweet thisAlerts:
@96turnerriFeb 03.2004 — what about this not sure what this will return as do not have 2 monitors on this pc

screen.availWidth
Copy linkTweet thisAlerts:
@blawauthorFeb 03.2004 — No, that's the problem. Neither screen.width nor screen.availWidth work. The screen object seems to only ever refer to the primary screen and it seems only one screen object exists. Clearly, the window and document objects wouldn't work, and if there is a second screen object representing the available space on the second monitor, I certainly don't know how to access it.
Copy linkTweet thisAlerts:
@96turnerriFeb 03.2004 — well if that doesnt work AFAIK it is not possible sorry to say
Copy linkTweet thisAlerts:
@blawauthorFeb 03.2004 — Dammit. Thanks anyways for trying, Rich.
Copy linkTweet thisAlerts:
@96turnerriFeb 03.2004 — no proplem if i do find a solution, i will let you know
×

Success!

Help @blaw spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...