SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast ianhales's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    recording screen res (php)

    I have a log file, and would like to store the user's screen resolution in it so that I can get a better idea of how to design my site. I know how I could read it in Javascript, but how would I tansfer this to PHP and record it in my logfile? Or is there an easier way to o it? (My log file uses flat-file storage in a .html file).
    Thanks in advance for any advice you can offer.
    Inhale Design Freelance webdesign and programming

    Follow us on Twitter!

  2. #2
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could perhaps make your site load an 1px image that would run some php script with the javascript generated resolution in the url, eg
    <img src='log.php?resolution=1024x860'

    just an idea though, never done anything like this ...
    - website

  3. #3
    SitePoint Zealot Egghead's Avatar
    Join Date
    Feb 2002
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use JavaScript to store the screen resolution data in a cookie. Then you would use either the $_COOKIE or $_REQUEST superglobal to access the variables in PHP...
    Code:
    <script language="javascript">
    <!--
    getScreenRes();
    function getScreenRes()
    {
       // ... shortened script blah, blah ...  
       var screen_res  = screen.width + "x";
       var screen_res  = screen_res + screen.height;
       document.cookie = screen_res;
    }
    //-->
    </script>
    And the PHP...
    PHP Code:
    <?php
    if(isset($_COOKIE['screen_res'])) // check it exists
    {
       
    $screen_res $_COOKIE['screen_res']; 
       
    // now you can use $screen_res for whatever
    }
    ?>
    I've never tried this so if you get a solution let us know how it goes.

  4. #4
    SitePoint Enthusiast ianhales's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks. I'll try that ASAP.
    Inhale Design Freelance webdesign and programming

    Follow us on Twitter!


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
  •