...

View Full Version : Screen res varible for php?



Crowds
05-04-2006, 12:55 PM
I know that being server side, php cannot detect screen res. But I am wondering If I could use Javascript to detect the screen res and then use PHP to load the appropriate include ().
What I have is a site that ports well between different resolutions apart from its header (which contains the main nav and search input box) which hangs off the right hand side. As the header is an include I figure that I could make two versions of this include. And load the appropriate one depending on a screen width varible say < 1024 or > 1024.

So I have the following javascript to detect screen res width

<script language='Javascript'>
<!--
if (screen.width <= 800){document.location="8by6/index.php";}
else if (screen.width <= 1024){document.location="10by24/index.php";}
if (screen.width > 1024){document.location="10by24/index.php";}
//-->
</script>

But this is just telling the browser to go to a certain page in a certain dir.
How can I alter the
{document.location="10by24/index.php";} element
to a varible that PHP can pick up on and use acoridingly ?

Crowds

Crowds
05-04-2006, 04:34 PM
Would this establish the variables ready for PHP to call them ?

<script language='Javascript'>
<!--
if (screen.width <= 800){var sr = "800";}
else if (screen.width <= 1024){var sr = "1024";}
//-->
</script>

Crowds

felgall
05-05-2006, 12:37 AM
The only way Javascript can provide information to PHP is either by loading a new page with the values passed in the search string or by using Ajax.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum