Jump to content

How To Read Screen Resolution Right With Ie8


Guest Jacek

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...