Hi, I recently had to change the name of my hompage document to index.php?w=y and that will dispaly the homepage. When you just go to index.php it detects the users window size and then re-directing you to index.php?w=y or index.php?w=n depending if its less than 860px wide. index.php is written in javascript, which then re-directs to the actual page. I have a command box,(where a user can enter in a command, like "PAY BILL" or "FORUMS" and it transfers it to the same page in which it was on. Then in an if command it dispalys "NOTE: Command Not reconized" or somthing. If it is forums lets say, then it will have "header(location:forums.php);" SO I decided to use cookies to set up the whole thing. It would only Detect the users screen size if the cookie wasn't set.
Here is the php Code:
NOTE:THE CODE ABOVE IS A SMALL SNIPPLET OF CODE WITH MANY OTHER LINES THAT WERE IRRELAVENT TO THE PROBLEM, WERE TAKKEN OUT.PHP Code:$widthOdoc = $_GET['w'];
$window_size = $_COOKIE['window-size'];
//set cookies
if(!$window_size|| $widthOdoc)
{
setcookie('window-size', $widthOdoc);
$cookie_is_set = "yes";
}
else
{
$cookie_is_set = "no";
}
$window_size = $_COOKIE['window-size'];
//DOCUMENT START///////////////////////////////////////PART 04
//This is where I add a whole bunch of doctypes, metas, etc.
//DOCUMENT/////////////////////////////////////////////PART 05
//Find out what size the document is.
if(!$widthOdoc && $cookie_is_set=="no")
{
echo "<title>Please Wait...</title>\n</head>";
echo '<script type="text/javascript">
onload=function(){
var w = window.innerWidth? window.innerWidth : document.body.clientWidth? document.body.clientWidth : 640;
if(w>864)
window.location="index.php?w=y";
else
window.location="index.php?w=n";
}
</script>';
}
else
{
echo "DEBUG: Width O Doc: |$widthOdoc| COOKIE[Window- Size]: |$window_size| Is the Cookie set? |$cookie_is_set|";
//THE REST OF MY SITE IS HERE
}
Please Help, Why dosent it work? Here is a futher link to my site in testing:
http://www.klein-onlineblog.com/test.../ohp/index.php





Bookmarks