简体   繁体   English

您如何使用javascript检测用户是否有多台显示器?

[英]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? 是否可以使用javascript检测用户是否有多个监视器? And additionally if the monitors are "cloned" or in "extended desktop" mode? 另外,如果显示器是“克隆”或处于“扩展桌面”模式?

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 ,可以很安全地说用户有两个监视器。


PS This will only cover situations where the use has side-by-side, non-cloned displays. PS这将仅涵盖使用并排非克隆显示的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM