Joseph Ghassan
Joseph Ghassan

Reputation: 759

Resizing browser window in Dual Display mode

it it possible to resize the browser window width to fit 2 monitors through JavaScript ?

Let's say we have 2 monitors with same resolutions : 1280x760.

is it possible to expand the width of the browser to fit 2 monitor? that 1280 X 1280.

thanks.

Upvotes: 1

Views: 1354

Answers (2)

Spudley
Spudley

Reputation: 168735

Firstly: Don't do this! Your users will hate you for it.

Secondly, there are a number of possible configurations possible for users who have more than one monitor.

Some users will have them set to be treated as a single extra-large display; others will have them working more independantly of each other. A colleague of mine has a display-splitter hardware which means that although he has two monitors, the PC only sees one, so when he maximizes his windows, they cover both screens. My set up on the other hand is different; when I maximize, the window expands to fill a single monitor.

Some users will even have different monitor sizes and different resolutions betweeen their monitors. I know one person who has one monitor in landscape mode, and the other rotated 90 degrees in portrait mode.

A lot of these things will make it phyically impossible to have a window that is maximized across all monitors, so even if you could make it work for some users, it wouldn't work for everyone.

Assuming you do manage to get the browser window stretched across both monitors, you now have the problem of working out how to layout your page without your text and graphics being split by the edges of the monitors. Your browser won't know where the monitor edges are, so you could easily end up with important parts of your page content being broken in half which could make your site virtually unreadable.

Even if you know in advance exactly what the user's screen resolution is going to be, you still have this problem because you don't know what the user's browser window looks like. They may have the history or bookmarks side-panels open. Their desktop settings may be different too; they may have their Windows taskbar aligned on the side of the screen rather than the bottom. None of these things are in your control, and will affect the screen space available to your browser, which in turn means you can't predict where the edges of the monitors will be even in an environment where you know the screen resolution.

In short, I don't believe it's possible, and I don't believe it's desirable. I strongly recommend not doing it.

Upvotes: 2

Colin Fine
Colin Fine

Reputation: 3364

To quote from David Flanagan, "Javascript, The Definitive Guide" (5th edition), Section 14.4.3:

"The Window object defines methods that move and resize a window. Using these methods is typically considered very poor form: the user should have exclusive control of the size and position of all windows on her desktop. Modern browsers typically have an option to prevent JavaScript from moving and resizing windows, and you shuld expect this option to be on in a sizable percentage of browsers" (emphasis added)

Upvotes: 2

Related Questions