Closed Thread
Results 1 to 7 of 7

Thread: Screen resolution

  1. #1
    NeedHelp Guest

    Screen resolution

    How do I get the screen resolution using PHP?

  2. CODECALL Circuit advertisement

     
  3. #2
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20
    The screen resolution of the server or the client?
    To get the resolution of the server you would have to use the exec() function and execute the unix/dos command to get the resolution (are there any?)

    But you probably mean the client, which you would use JavaScript
    Code:
    <script type="text/javascript"> 
      document.write(window.screen.width + ' x ' + window.screen.height); 
    </script>
    You can write the resolution to a cookie and use the php cookie functions to grab the resolution from the cookie file.

  4. #3
    Jordan Guest
    To get the client records you will need to use Javascript and there is no way that PHP can receive this value since it is server side.

  5. #4
    NeedHelp Guest
    Hmm, I really just need to make an if statement and if their resolution is lower than a certain value display an error message. Do I need to do a cookie and everything for that?

  6. #5
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20
    How would you compare the value?
    Code:
    if(<script type="text/javascript"
      
    document.write(window.screen.width ' x ' window.screen.height); 
    </script> < 1024)
    echo "Error"; 
    Im pretty sure if you want to use php to display the error message you have to use cookies, unless there is another way to store the width/height. You could always of course display the error in JavaScript. Im no JS expert but maybe something like this

    Code:
    <script type="text/javascript">
    if(window.screen.width < 1024)
    allert("Your screen is too small");
    </script>

  7. #6
    Jordan Guest
    What Sidewinder suggested would work well. You could also create a dynamic page using JavaScript or simply forward the user to an error page (like res.html) with the same logic above.

  8. #7
    NeedHelp Guest
    That works. I'll figure out something. Thank you.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Screen resolution issue and getting rid of gaps around the edges of the screen...
    By HumansAreFriendsNotFood in forum HTML Programming
    Replies: 10
    Last Post: 06-07-2010, 11:07 AM
  2. JavaScript:Tutorial, Screen Resolution
    By TcM in forum JavaScript Tutorials
    Replies: 7
    Last Post: 04-01-2010, 08:12 AM
  3. screen resolution problem
    By jwxie518 in forum HTML Programming
    Replies: 3
    Last Post: 01-06-2010, 03:59 PM
  4. Screen Resolution problems
    By fread in forum HTML Programming
    Replies: 7
    Last Post: 10-21-2009, 08:50 PM
  5. Screen Resolution problem
    By Brandon W in forum JavaScript and CSS
    Replies: 5
    Last Post: 11-25-2008, 12:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

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