Hey guys,

I'm trying to do the following:

If a user screen resolution is more than 1024 X 768 show him/her an image that is 1000 pixels and if the browser resolution is less than 1024 show him/her 800 pixels size.

Is that possible at all?

    java script can get screen resolution, but php beng server side, cant.

      Probably the closest thing that exists in PHP is [man]get_browser[/man] and it does not detect screen resolution. I'm pretty sure you'll need to use Javascript for that. Something like this might help:

      <html>
      <script>
      <!--
      function show(){
        if (!document.all&&!document.layers&&!document.getElementById) {
          alert('this will not work on your browser');
        }
        document.getElementById('width').value=screen.width;
        document.getElementById('height').value=screen.height;
        document.getElementById('colorDepth').value=screen.colorDepth;
        document.getElementById('pixelDepth').value=screen.pixelDepth;
        document.getElementById('availWidth').value=screen.availWidth;
        document.getElementById('availHeight').value=screen.availHeight;
      }
      //-->
      </script>
      <body onload="show();">
      <form>
      width:<input id="width"><br>
      height:<input id="height"><br>
      colorDepth:<input id="colorDepth"><br>
      pixelDepth:<input id="pixelDepth"><br>
      availWidth:<input id="availWidth"><br>
      availHeight:<input id="availHeight"><br>
      </form>
      </body>
      </html>
      

        And since Javascript could then load the correct URL based on the resolution, you're pretty much looking at a purely Javascript solution.

        If you really wanted to complicate things a bit, you could have JS grab the screen resolution and send that back to a PHP script which would output the correct image, ex. creating a new Image in Javascript, pointing its source to mysite.com/image.php?res_h=1024&res_w=768, and then attach it to some element inside your HTML document.

          ...and what if the browser resolution is less than 800? 🙂

            Weedpacket;10909506 wrote:

            ...and what if the browser resolution is less than 800? 🙂

            ...like my iPod Touch?

              Write a Reply...