Jason Axelson
Jason Axelson

Reputation: 4665

How do you use javascript to detect if a user has multiple monitors?

Is it possible to use javascript to detect if a user has multiple monitors? And additionally if the monitors are "cloned" or in "extended desktop" mode?

Upvotes: 0

Views: 3503

Answers (2)

Steve
Steve

Reputation: 4975

You can check if a screen is extended.

window.screen.isExtended

The only place I can find info on it is here. I think it is still a draft spec.

Support (17/05/22):

  • ✅ Chrome (v101)
  • ⛔️ Firefox (v100)
  • ⛔️ Safari (v15.4)

Upvotes: 1

Dendromaniac
Dendromaniac

Reputation: 394

I'm pretty sure it's impossible to find that out but you can make an educated guess using the following (untested) code:

var dual_monitor = ( (screen.width / screen.height) > 2 )

This will test if the (total) monitor width is at least twice as wide as the height, the closest (normal) ratio is 16:9, even this would return false, so If dual_monitor == true, it is fairly safe to say that the user has two monitors.


P.S This will only cover situations where the use has side-by-side, non-cloned displays.

Upvotes: 0

Related Questions