Re: Simple question
| From: | Chris Hayes | Date: | Tue, 27 Apr 2004 10:06:09 +0000 |
| Subject: | Re: Simple question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-184742@lists.php.net to get a copy of this message | ||
At 09:35 27-4-04, you wrote:
probably? ;-) I need to determine users resolution and place objects on the page according to that information. I'm trying to get this work but it doesn't. It always ends up with echoing "large". I really don't know why. Can anyone help me?It seems that you expect a userside javascript in a constant to be executed on the server during the parsing of PHP. Of course PHP is executed first on the server by the server, then the resulting HTML page with javascripts is send to the user, where the javascript is executed by the browser. You need to use some page reload trick or find another way to get user resolution information.
Here's the script: <?php DEFINE('RESOLUTION','<script language="javascript">document.write(screen.width+" x "+screen.height);</script>'); $res = RESOLUTION; echo "$res"; echo "<br>"; echo (gettype($res)); echo "<br>"; if ($res == '800 x 600'){ echo "small"; } else if ($res == '1024 x 768'){ echo "medium"; } else { echo "large"; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php