Get maximium width and height of the screen

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anandaraman
    New Member
    • Feb 2007
    • 8

    Get maximium width and height of the screen

    Hi all, i want to get the maximum width and height of the screen. could anyone telll me the right coding for this
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    I'm not sure if you can do that with php.

    PHP is run server side so it only gets limited info about the client. Browser type and such.

    I would consider using javascript for this kind of thing.

    Comment

    • aniltc
      New Member
      • Jul 2006
      • 17

      #3
      yes you are right we can't do in php use javascript

      check the below code

      part1-javascript

      [HTML]<script type="text/javascript">

      width = screen.width;
      height = screen.height;

      if (width > 0 && height >0) {
      window.location .href = "http://localhost/main.php?width= " + width + "&height=" + height;
      } else
      exit();

      </script>
      [/HTML]

      part-2 php (main.php)
      [PHP]
      <?php
      echo "<h1>Screen Resolution:</h1>";
      echo "Width : ".$_GET['width']."<br>";
      echo "Height : ".$_GET['height']."<br>";
      ?>[/PHP]

      I hope this would solve the problem

      Comment

      • anandaraman
        New Member
        • Feb 2007
        • 8

        #4
        Thank a lot. its working....

        Comment

        Working...