Reply to Re: why does this not work?

Your name:

Reply:


Posted by Oliver Grδtz on 09/28/05 00:38

Ross schrieb:
> $width = " <script> document.write(screen.width); </script>";
> //$ross= intval($width);

Yes, this is and will always be zero, because you are evaluating a
string to an integer value.

> echo $width;
> if ($width < 1064) {
> echo "lower";
> $style= "style1.css";
>
> }
> else {
> $style= "style2.css";
>
> }

OK, no I could insert the stuff about server side and client side.
What you want to do is learn about the user's screen width. First of
all, this is a bad idea if I you want to use it for design purposes like
in this case where you include different CSS files. If I have a
1600x1200 screen, I can easily open a browser window at 640x480. And
now? And even if you don't evaluate the screen width but the browser
window's width: What about me resizing the already rendered page? Think
about better designing the page so you don't need to switch the CSS...

OK, enough of evangelism. If you really want to do what you told there:
Evaluate the JavaScript on your entry page. Then do a redirect to that
same page and insert the value into the URL (e.g.
index.php?scrwidth=1280). You can then access this from PHP via $_GET.
It is a good idea to store this value in the session once received so
you don't have to send it around on each link.


AllOLLi


____________
63,000 bugs in the code, 63,000 bugs,
ya get 1 whacked with a service pack,
now there's 63,005 bugs in the code!!

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация