问题
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..
回答1:
It's not possible to detect the physical dimensions. Resolution is as close as you're gonna get.
来源:https://stackoverflow.com/questions/12051071/detect-physical-dimension-of-monitor