Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, Is there a way to get the si

Status
Not open for further replies.

elzbieta

Programmer
Oct 15, 2003
1
AU
Hi,

Is there a way to get the size of the window in inches through javascript?

Thanks

Elzbieta
 
You will have to do your own (fuzzy) math. You can get the size of the window in pixels (document.width, document.height), but any attempt to get the actual size in inches, is, well... impossible. Everyone's got a different size monitor, and everyone's got a different resolution setup, so the best you can do is guess.

Generally, for low-res (640 x 480) configurations, you can estimate about 72 pixels per inch, for a 15-inch monitor. But this could be the same for a 17-inch monitor setup for 800 x 600. For a modern high-res monitor setup at about 1024 x 768 or 1280 x 1024, you can estimate about 96 pixels per inch. But in reality, the range can be anything in between, or higher.

There are also ways to get the resolution and color depth setup, so you can possibly estimate a little better. The methods are of course different for Netscape and IE, not to mention probably unavailable on most other browsers.

For more info, go to:

and click on the DHTML/Scripting link.

and go to the Documentation area for Javascript documentation. The Client-Side Javascript Reference is probably the most helpful. [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top