<!doctype html> <head> <title>Mobile-Web-App: Test Javascript</title> <meta charset="utf-8"> <script> function myOnLoad(){ var devicePixelRatio = window.devicePixelRatio; eleRatio = document.getElementById("ratio"); eleRatio.innerHTML = devicePixelRatio; } window.onload = myOnLoad; </script> </head> <body> <h1>Mobile-Web-App: detect device pixel ratio</h1> devicePixelRatio: <b id="ratio"></b> </body> </html>
Wednesday, July 4, 2012
Get screen density with JavaScript using window.devicePixelRatio DOM property
In mobile web app (specially in Android, various screen densities are provided), we can get screen density with JavaScript using window.devicePixelRatio DOM property.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment