6

Well, simple situation. Is it possible to detect if a user has a dual monitor setup from a web application? If this is possible, is it possible to open a child browser page on this second monitor, so the new window doesn't overlap the old one?

Reason why I ask: I'm working on a web application and at home I have a dual-monitor system. When I go to the administration part of this site, I want it to open in a new browser, preferably on the other desktop. Of course, I could just click, then drag the new window, but doing this automatically seems more fun. :-)

Don't think JavaScript has the proper functions for this. How about Java itself?

Wim ten Brink
  • 25,901
  • 20
  • 83
  • 149
  • 2
    I wouldn't encourage this. This is technically un-expected behavior. If you opened something on my other monitor, it would annoy me :) I may have important stuff going on over there that I don't want covered with another window. – Sampson Aug 18 '09 at 13:26
  • 4
    Well, it's for personal use so the one user who'll use it won't be annoyed by it. ;-) – Wim ten Brink Aug 18 '09 at 13:46

2 Answers2

3

I don't think you'll be able to directly detect a dual monitor setup, but you can probably make a good guess by looking at their screen resolution, using javascript's screen.width and screen.height. If the ratio of the width to the height is 8:3, its a good chance they have 2 standard 4:3 monitors side by side. You can do a similar calculation for 16:9 or 16:10.

maxpower47
  • 1,666
  • 1
  • 10
  • 14
  • 9
    On Windows 7 using Chrome, Firefox, Safari, Opera and Internet Explorer, only the dimensions of the monitor the browser is active in are detected so this wouldn't work. – Marcel Mar 28 '11 at 09:40
  • Any chance to detect also the second monitor resolution, in order to use maxpower47's idea? – Luca Detomi Dec 16 '14 at 09:54
1

Using maxpower47's suggestion about resolution, the only way to display the page on the other monitor would be to open a popup, and use the options to set the top, right, width and height properties so the window will appear on the second monitor in a decent size.

Here is a link that describes how to do this: http://www.netmechanic.com/news/vol4/javascript_no7.htm

Jason Miesionczek
  • 14,268
  • 17
  • 76
  • 108
  • Did anyone try this solution? Is it known to work on different browsers? – Ashraf Sabry Jan 16 '13 at 14:56
  • Firefox (v38) only allows `window.open()` to open a new window in the main monitor, ignoring `top` and `left` settings that exceed the monitor resolution. Also, subsequent calls to `window.moveTo()` will not reposition the window outside the main monitor. – David R Tribble Jun 24 '15 at 15:30
  • Because the aforementioned link is dead, here is the code taken from the Wayback Machine: `window.open(, 'nextWin', 'right=0, top=20, width=350, height=350, toolbar=yes, scrollbars=yes, resizable=yes')`. – Doc Davluz May 04 '17 at 09:28