Detecting the system DPI/PPI from JS/CSS?

<div id=’testdiv’ style=”height: 1in; left: -100%; position: absolute; top: -100%; width: 1in;”></div> <script type=”text/javascript”> var devicePixelRatio = window.devicePixelRatio || 1; dpi_x = document.getElementById(‘testdiv’).offsetWidth * devicePixelRatio; dpi_y = document.getElementById(‘testdiv’).offsetHeight * devicePixelRatio; console.log(dpi_x, dpi_y); </script> grabbed from here http://www.infobyip.com/detectmonitordpi.php. Works on mobile devices! (android 4.2.2 tested)