#1
  1. No Profile Picture
    Phil
    Guest
    Devshed Newbie (0 - 499 posts)
    Hi,
    Can someone tell me how to obtain the resolution of the client browser in javascript. I don't found this in the navigator object.

    Regards
  2. #2
  3. No Profile Picture
    webcoder
    Guest
    Devshed Newbie (0 - 499 posts)

    Hi Phil,

    You might be a little confused here - of course, I might be a little confused too?

    The term 'Resolution' describes a monitor setting of the user's computer. It's not a browser setting and I don't think you can access that info. from JS or from the web browser.


    ------------------
    Matthew J. Flynn
    http://webcoder.net
  4. #3
  5. No Profile Picture
    WhiteNight
    Guest
    Devshed Newbie (0 - 499 posts)
    You can get the current Resoultion through JS
    Here is how to do it

    <SCRIPT LANGUAGE=javascript>var xy = navigator.appVersion;xz = xy.substring(0,4);document.write('<B> ',screen.width,' x ',screen.height,'</B>')</SCRIPT>

    This will write it to the document.

    ------------------
    L8Rz
    WhiteKnight
  6. #4
  7. No Profile Picture
    Striker
    Guest
    Devshed Newbie (0 - 499 posts)
    Here is the same thing, but it notifies the client if the resolution does not match the anticipated design resolution.

    <head>
    </script>
    <script language="JavaScript1.2">
    var winX = screen.width;
    var winY = screen.height;

    if (winX <= '640') {
    newWindow = window.open('reswarning.htm', '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="no",width=300,height=225');
    }
    </script>
    </head>

    In the reswarning.htm (pop-up window) file, you can also insert this piece of JavaScript code for additional enhancement.


    <script language="JavaScript1.2">
    var winX = screen.width;
    var winY = screen.height;

    document.write('Your screen resolution is ' + winX + ' x ' + winY + ', which is below the recommended size for this application. If possible, please reset your screen resolution to 800 x 600 or higher. Thank you!');
    </script>

    --Good Luck



    ------------------
    Striker
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Posts
    72
    Rep Power
    6
    The other replies are incorrect, the code they gave you will give you the screen resolution, not the browser width.

    See the website:
    http://www.w3schools.com/jsref/prop_win_innerheight.asp

    Syntax

    Get:
    window.innerWidth
    window.innerHeight

    Set:
    window.innerWidth=pixels
    window.innerHeight=pixels
  10. #6
  11. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,122
    Rep Power
    4258
    This thread is also over 12 years old. Next time please check the last post date when you reply to a thread that you found from a search query.

    Please do not post links to that site here. There are better resources elsewhere. I recommend you read this: W3Fools: A W3Schools Intervention
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Posts
    72
    Rep Power
    6
    Sorry I know the posts were old, I was just hoping to help future searchers who come upon this topic like I did. W3schools was not even the first site I found the info on... but I closed out the original site and couldn't find it again, then when I searched W3 was the first one I found that had the same info.

    The info on there is correct... it works anyway.

    I see other help sites listed on the page about W3... I'll check them out.
    Last edited by wakerunner; November 7th, 2012 at 02:59 PM.
  14. #8
  15. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,122
    Rep Power
    4258
    It's good to make sure correct information is posted, but there is so much information available on the web (and on these forums) that is now outdated or just plain incorrect from the beginning, that correcting things that are obviously old like this is often more trouble than it's worth.

    Don't let the "W3" in the name confuse you! W3C and W3Schools are two completely separate organizations. "W3" is simply another way to write "WWW", which is short for "world wide web".

    I'm not aware of a one-stop-shop like W3Schools, but there are many better references for individual (or smaller groups of) languages elsewhere.
    For JavaScript and DOM, I mainly use MDN (Mozilla Developer Network) and MSDN (Microsoft Developer Network):
    https://developer.mozilla.org/en-US/docs/JavaScript
    https://developer.mozilla.org/en-US/docs/DOM
    MSDN HTML and DHTML Reference
    JScript (ECMAScript3)

    For CSS, I mainly use the official specs (I'm not going to list all of the CSS3 modules, if you need help finding one, just ask) and SitePoint's CSS Reference:
    http://www.w3.org/TR/CSS21/
    http://www.w3.org/TR/css3-selectors/
    http://www.w3.org/TR/css3-background/
    http://www.w3.org/TR/css3-box/
    http://www.w3.org/TR/css3-ui/
    http://reference.sitepoint.com/css

    For HTML (and XHTML), I use the official specs but SitePoint's HTML Reference is good too:
    http://www.w3.org/TR/html401/
    Working Draft of the HTML5 specifications
    http://www.w3.org/TR/xhtml1/
    http://reference.sitepoint.com/html

    For PHP, I use the official manual: http://php.net/manual/en/

    For MySQL, I generally use the official documentation: http://dev.mysql.com/doc/

    Comments on this post

    • Winters agrees
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Posts
    72
    Rep Power
    6
    Great! Thanks for all the info!

Similar Threads

  1. sizing the webpage according to the browser resolution
    By woow in forum HTML Programming
    Replies: 2
    Last Post: December 16th, 2003, 10:32 AM
  2. browser timeout vs. PHP timeout
    By odv_fish in forum PHP Development
    Replies: 4
    Last Post: November 13th, 2003, 09:48 AM
  3. problem accessing browser over network
    By -Dman100- in forum Networking Help
    Replies: 0
    Last Post: October 22nd, 2003, 07:49 PM
  4. communicate to browser without erasing current page
    By jmiller in forum PHP Development
    Replies: 3
    Last Post: August 3rd, 2002, 04:16 PM
  5. Detect browser resolution.....
    By mfkoo in forum PHP Development
    Replies: 1
    Last Post: June 12th, 2000, 06:44 AM

IMN logo majestic logo threadwatch logo seochat tools logo