检测显示器的物理尺寸 [英] Detect Physical dimension of Monitor
本文介绍了检测显示器的物理尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用JavaScript或Flash?
我尝试了以下函数:
var dpi_x = document.getElementById('testdiv')。offsetWidth;
var dpi_y = document.getElementById('testdiv')。offsetHeight;
var width_in = screen.width / dpi_x;
var height_in = screen.height / dpi_y;
var diagonal_in = Math.round(10 * Math.sqrt(width_in * width_in + height_in * height_in))/ 10;
但它并不显示固定的对角线值...因为当我改变分辨率显示...
在我想要的固定尺寸像16.5...我的意思是,它应该是固定的任何特定的显示器..
解决方案
不可能检测物理尺寸。
I want to get the display dimensions of my monitor.
Is it possible to do with JavaScript or Flash?
I tried the following function:
var dpi_x = document.getElementById('testdiv').offsetWidth;
var dpi_y = document.getElementById('testdiv').offsetHeight;
var width_in = screen.width / dpi_x;
var height_in = screen.height / dpi_y;
var diagonal_in = Math.round(10 * Math.sqrt(width_in * width_in + height_in * height_in)) / 10;
but it doesn't show the fixed diagonal value... because when I change the resolution of the display...
Where as I want the fixed dimension like 16.5"... I mean, it should be fixed for any specific monitor..
解决方案
It's not possible to detect the physical dimensions. Resolution is as close as you're gonna get.
这篇关于检测显示器的物理尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文