By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,290 Members | 1,631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,290 IT Pros & Developers. It's quick & easy.

Monitor resolution

P: n/a
How to get monitor resolution using javascript?
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
*Mario* wrote:
How to get monitor resolution using javascript?

var strDPI = prompt("What is D.P.I. of your display?");
Andrew Urquhart
- FAQ:
- Archive:
- Contact me:
- Apologies for the wrong timestamp on my post - blame my ISP
Jul 23 '05 #2

P: n/a
Mario wrote:
How to get monitor resolution using javascript?

The question you should be asking is why you want to do this.

The resolution of the "monitor" has only a passing relationship
with the dimensions of the Web browser. It simply defines what
might be the maximum possible *outer* dimensions of the browser

It tells you nothing about how big the *viewport* on the browser
is. Given the ability of browsers with customizable toolbars the
viewport could be anything from a few pixels smaller then the
outer dimensions of the browser to hundreds of pixels smaller (I
once saw a user using Internet Explorer with about 8 toolbars,
their viewport was perhaps 1/3 of the overall height of the outer
dimensions of the Web browser window).

For people with multiple monitor configurations, the dimensions
you retrieve might be the size of all monitors both horizontally
and vertically, not very useful because it's highly unlikely
anyone with 2 or more monitors would maximize a Web browser
across all of their monitors.

If your idea is to "maximize the user's browser for them", this
is an _extremely_ bad idea.

First, it's more and more likely attempting to do such a thing is
simply going to fail due to browser add-ons or built-in ability
to ignore such requests.

Second, people with 2 or more monitors might not appreciate you
spreading their browser window over all their displays (of
course, anyone with 2 or more monitors probably disable your
ability to resize the browser in the first place).

Third, it's really really really RUDE to mess with the user's
browser dimensions. It shows a lack of respect for your visitors
and somehow implies you know better then they do.

All that said, if you want this information for survey purposes
or some other reason, you can retrieve the size of the available
desktop area using:

screen.width and screen.height

To obtain the area of the desktop available to actually display
windows in (minus any taskbars or toolbars) its:

screen.availWidth and screen.availHeight

Grant Wagner <gw*****>
comp.lang.javascript FAQ -

Jul 23 '05 #3

P: n/a
Mario wrote:
How to get monitor resolution using javascript?

You cannot and even if you could, what would it serve anyway?
Display resolution != desktop size != browser window size != viewport size.
[psf 3.7]
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.