Monitor resolution

Discussion in 'Javascript' started by Mario, Jul 29, 2004.

  1. Mario

    Mario Guest

    How to get monitor resolution using javascript?
    Mario, Jul 29, 2004
    1. Advertisements

  2. Grant Wagner

    Grant Wagner Guest

    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 <>
    comp.lang.javascript FAQ -
    Grant Wagner, Jul 29, 2004
    1. Advertisements

  3. 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]

    Thomas 'PointedEars' Lahn, Jul 30, 2004
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew FPGA
    Andrew FPGA
    Sep 26, 2005
  2. Jean Paul

    getting resolution of monitor

    Jean Paul, Oct 6, 2004, in forum: Java
    Jean Paul
    Oct 7, 2004
  3. akbar
  4. ScottZ
    Jorgen Grahn
    Nov 2, 2008
  5. Sivaswami Jeganathan

    Modify asp page according to Monitor resolution.

    Sivaswami Jeganathan, Mar 27, 2006, in forum: ASP General
    Mar 28, 2006

Share This Page