Javascript – How to access screen display’s DPI settings via javascript?


Is there a way to access the screen display's DPI settings in a Javascript function?

I am trying to position a HTML panel on the page and when the user's DPI is set to large (120), it throws the position off. I need to be able to know what the DPI is so I can adjust the position accordingly.

Best Solution

Looks like you can use the 'screen' DOM object in IE, its got properties for deviceXDPI, deviceYDPI, logicalXDPI, logicalYDPI.

Here's a solution from (i havent tried it, seems like a total hack :) Just create something 1 inch wide and measure it in pixels!

#dpi {
    height: 1in;
    left: -100%;
    position: absolute;
    top: -100%;
    width: 1in;
<div id="dpi"></div>