Jump to content

How To Read Screen Resolution Right With Ie8


Guest Jacek
 Share

Recommended Posts

At http://www.w3schools.com/js/tryit.asp?file..._browsermonitor I receive wrong reading of my screen resolution values with IE8:Screen resolution: 1024*640Available view area: 1024*618Color depth: 32Buffer depth: 0DeviceXDPI: 120DeviceYDPI: 120LogicalXDPI: 96LogicalYDPI: 96FontSmoothingEnabled: falsePixelDepth: undefinedUpdateInterval: 0My computer has non-standard DeviceXDPI and DeviceXDPI values, which are equal to 120 and not to 96. When I modify a part of the javascript code I receive right result:Screen resolution: 1280*800Available view area: 1280*772.5Here is the snippet: document.write("Screen resolution: ");width = screen.width; height = screen.height;availwidth = screen.availWidth;availheight = screen.availHeight;if (typeof(screen.deviceXDPI) == 'number') {width *= screen.deviceXDPI/screen.logicalXDPI;height *= screen.deviceYDPI/screen.logicalYDPI;availwidth *= screen.deviceXDPI/screen.logicalXDPI;availheight *= screen.deviceYDPI/screen.logicalYDPI;}document.write(width + "*" + height);document.write("<br />");document.write("Available view area: ");document.write(availwidth + "*" + availheight);document.write("<br />");document.write("Color depth: "); :) Best regards

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...