OSX + JavaScript + Multiple Monitors

As I posted a while back, there’s no real definitive help for doing javascript with multiple monitors. Now that I’m on Mac OSX, I thought I’d update with the info for that platform.

Firefox sees various values differently on the main screen and on the secondary screen… here is a quick table with the info — for reference sake, the secondary display is vertically positioned above the primary display, and my Dock is on the left side of the primary screen…

Variable Primary Secondary
Actual Resolution 1440×900 1920×1200
screen.top 0 -1200
screen.left 0 -269
screen.width 1440 1920
screen.height 900 1200
screen.availTop 22 -1200
screen.availLeft 53 -269
screen.availWidth 1387 1920
screen.availHeight 878 1200

So, you’d think the same script would work fine… but on the primary screen, moving to (0,0) put you at (availTop, availLeft), aka (22,53) because of the Dock and the OSX menu.

The code that worked for me…

resizeTo( 1024, screen.availHeight );
var screenTop = screen.availTop;
if( screen.availHeight != screen.height ) {
    screenTop = 0;
}
moveTo( screen.availLeft, screenTop );

Javascript on Multiple Monitor Systems

I have a preference to keep my browser windows a certain width (1024 pixels for various reasons), flush against the right side of my monitor display, and taking the full height of the screen.  To do this, I have the following javascript on my start page:

resizeTo( 1024, screen.availHeight );
moveTo( (screen.availWidth - 1024), 0 );

For some reason though, Firefox has always had some strange behavior when running this script on my systems with multiple monitors.

Continue reading Javascript on Multiple Monitor Systems