A challenge for JavaScript monkeys...
Category None
Is there a way in a browser to detect if you are running in a dual monitor setup? A way to get the dimensions of each monitor? My usual fall back for such questions, Google, has failed to find the goods.
Anyone know if it's possible? Possible with a Java applet?
Is there a way in a browser to detect if you are running in a dual monitor setup? A way to get the dimensions of each monitor? My usual fall back for such questions, Google, has failed to find the goods.
Anyone know if it's possible? Possible with a Java applet?
Comments
That said, if you run some test Javascript with those attributes on a dual screen system, I wonder what would happen? You could give this code a go (limited to available width and height, but you could easily add the other stuff):
function testScreen()
{
if (screen.availHeight)
{
alert("availHeight = " + screen.availHeight);
}
if (screen.availWidth)
{
alert("availWidth = " + screen.availWidth);
}
}
Posted by Ben Poole At 06:16:41 AM On 07/06/2005 | - Website - |
Unfortunately, I haven't found a good way to detect dual monitors either.
Posted by Jordan Ambra At 03:23:21 PM On 07/19/2005 | - Website - |
Here's the script I'm using:
oWindow = window.open(....)
oWindow.moveTo(0, 0);
oWindow.resizeTo(window.screen.availWidth, window.screen.availHeight);
I just want my window to perform the same function as when user presses "Maximize" button....
Posted by Yan At 05:26:36 PM On 07/29/2005 | - Website - |
Here's the clunky part, if you open a huge window, IE will reduce its size down to the largest that can be displayed on the two monitors. You can get the dimensions of the client area of that window (IE doesn't let you get the outter dimensions). With the dimensions of monitor one and the approximate dimensions of both monitors together, you can derive the approximate size of monitor 2.
What I've noticed in practice: I run a 1280x1024 monitor 2 with a 1024 x768 laptop monitor 1. The total dimensions I get are 2306x1007. Interestingly, I get this measurement even in I position this super sized window outside of the viewable desktop (i.e. left is @ 10000, top @ 0, hence I'm hiding that I'm measuring the monitors). Of course, the math would make is seem as though the second monitor's dimensions are 1282x1007 which is close but not exactly right. In any case, you can detect the second montior (window's clientWidth > screen.availWidth indicates more than more than one montior is involved) and you can get the approximate dimensions of the second monitor (much more accurate in width than height).
I've tested this with the second monitor @ 800x600 and the diensions returned were 1826x751. Clearly the least accurate dimension is the height. It appears the larger height is chosen as the basis for measurement.
Posted by Sam At 03:13:25 PM On 01/01/2006 | - Website - |