Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder ubik's Avatar
    Join Date
    Oct 2005
    Location
    westCoast, usa
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Detect Screen Resolution

    Hello, Greetings.

    Does anyone know if there is anyway to detect the user's Screen Resolution using javascript? I have noticed that:

    Code:
    screen.width
    works good with Internet Explorer but not in firefox, and im not even sure about any other browser
    "True knowledge exists in knowing that you know nothing."
    -Socrates

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    That works in Firefox. To quickly test it, type this in the FF address bar:
    Code:
    javascript:alert(screen.width)

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,640
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Of course screen resolution tells you nothing about the space available in the browser window to display the web page.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Regular Coder ubik's Avatar
    Join Date
    Oct 2005
    Location
    westCoast, usa
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv
    That works in Firefox. To quickly test it, type this in the FF address bar:
    Code:
    javascript:alert(screen.width)
    I noticed that Internet Explorer when on 800x600 resolution returns 800 width, when on 1024x768 resolution it returns 1024width.. But firefox, no matter what resolution I have my screen set to It always returns 800 ??
    "True knowledge exists in knowing that you know nothing."
    -Socrates

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Did you try that simple test on the address bar itself? What FF version are you using? I'm using FF 1.5 and it returns the correct width. And I'm sure it returns the same with older versions.

  • #6
    Regular Coder ubik's Avatar
    Join Date
    Oct 2005
    Location
    westCoast, usa
    Posts
    347
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ah yes, I just downloaded Mozilla Firefox 1.5 and it works now. But still i guess the script wouldnt be suitable because of all the people out there still using FF1.0 I wanted to make a script to detect screen resolution and redirect to specific resolution designs, but i guess ill be forced to make a splash page now. Fluid or liquid layouts are alright but my designs are highly graphical interfaced in width with no room for CSS textures. I would still use the script if it wasnt for Firefox 1.0, its not that it doesnt support the script, its just that it detects the resolution incorrectly if its anything other than 800 width.
    "True knowledge exists in knowing that you know nothing."
    -Socrates


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •