0

Possible Duplicate:
how to get user's screen resolution with PHP

Hy there,

is it possible to get the screen resolution of the user (maybe by php) and than call an if function to set up an image path in javascript related to this resolution?

Thx Sammy

Community
  • 1
  • 1
SammyFM
  • 51
  • 1
  • 3

1 Answers1

2

PHP doesn't know about the user's screen resolution, but you can of course use Javascript to detect it. Something like the following, for instance?

<script type="text/javascript">
  function setImageSrcBasedOnResolution()
  {
    document.getElementById("myImage").src="dynamicResolutionImage.php?size="
      + window.screen.width + "x" + window.screen.height;
  }

</script>

<body onLoad="setImageSrcBasedOnResolution()">
  <img id="myImage" src="temporaryLoadingImage.png" />
</body>

Where dynamicResolutionImage.php is some script that generates an image with the given size.

Frode
  • 5,600
  • 1
  • 25
  • 25