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?
是否可以使用javascript来检测用户是否有多个监视器?此外,如果监视器被“克隆”或“扩展桌面”模式?
1 个解决方案
#1
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.
这将测试(总)监视器宽度是否至少是高度的两倍,最接近(正常)比率是16:9,即使这将返回false,所以如果dual_monitor == true,则说是相当安全的用户有两个显示器。
P.S This will only cover situations where the use has side-by-side, non-cloned displays.
P.S这仅适用于使用并排,非克隆显示器的情况。
#1
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.
这将测试(总)监视器宽度是否至少是高度的两倍,最接近(正常)比率是16:9,即使这将返回false,所以如果dual_monitor == true,则说是相当安全的用户有两个显示器。
P.S This will only cover situations where the use has side-by-side, non-cloned displays.
P.S这仅适用于使用并排,非克隆显示器的情况。