Тостер: Диагональ в дюймах
HTML
<div id="inch" style="width:1in;"></div>
JavaScript
function getPxDiag(){
var scW = screen.width, scH = screen.height;
return "hypot" in Math
? Math.hypot(scW, scH)
: Math.sqrt( Math.pow(scW, 2) + Math.pow(scH, 2) )
;
}
function getInchDiag(){
var DPI = inch.offsetWidth;
return getPxDiag() * (1/DPI);
}
document.body.textContent = getInchDiag().toFixed(2);