/ Published in: JavaScript
Outputs the number of Pixels Per Inch in the current Device
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
getPPI : function(){ var DOM_body = document.getElementsByTagName('body')[0]; var DOM_div = document.createElement('div'); DOM_div.style = 'width: 1in; visibility:hidden;'; DOM_body.appendChild(DOM_div); var w = document.defaultView.getComputedStyle(DOM_div, null).getPropertyValue('width'); DOM_body.removeChild(DOM_div); return parseInt(w); }