Re: Simple question
| From: | De Greef S�bastien | Date: | Tue, 27 Apr 2004 12:17:52 +0000 |
| Subject: | Re: Simple question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-184752@lists.php.net to get a copy of this message | ||
hi,
you could write a cookie with javascript that contains the resolution in
the same script reload the current page and then in php just take the
cookie value or set default for users without java enabled users and or
cookies...
this is to write the cookie
function writeCookie(name, value, hours)
{
var expire = "";
if(hours != null)
{
expire = new Date((new Date()).getTime() + hours * 3600000);
expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire;
}
it's a dreamweaver snippet
and this will help you reload the current page
location = URLStr;
but do only it if the resolution cookie does'nt exist else you will loop
till crash lol :D
sorry for my bad english
Regards ...
"William Stokes" <kalles@operamail.com> a écrit dans le message news:
20040427073448.90842.qmail@pb1.pair.com...
> 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?
>
> 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";
> }
> ?>