After lots of problems trying to allow the visitor to switch styles using Javascript - but encountering browser incompatabiliti es!!
I decided to use PHP and found a simple way of doing it here:
http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/
But it's not quite working ... could someone help me with the syntax please
It consists of 4 parts:
1 -
2 - [ note - I changed on the 1st line their "<php" to "<?php" ]
[PHP]<php
if(isset($_COOK IE[’style’])){
$style=$_COOKIE[’style’];
} else {
$style=’default ’; //the name of default style file
}
?>[/PHP]
3 - [ A file called 'switch.php' consiting of the following: ]
[PHP]<?php setcookie(”styl e”, $_GET[”style”], time()+31536000 );
header(”Locatio n:”.$HTTP_SERVE R_VARS[”HTTP_REFERER”]);
?>[/PHP]
4 - [ and in the body: ]
[HTML]<a href=”/switch.php?styl e=default”>View page with Default style!</a>
<a href=”/switch.php?styl e=alternate”>Vi ew page with Alternate style!</a>[/HTML]
I named my 2 css files 'default.css' and 'alternate.css' and they are in the root directory.
When I click to select the default I get a 404 looking for:
http://test.domain.com/”switch.php?sty le=pp_style_tes t”
ie with quotes included around the argument ! (Nb - I've removed above the client's real domain name to protect the innocent ;-)
I also notice (when viewing the source) that the link has been passed by php as:
<link href=”’default’ .css” rel=”stylesheet ” type=”text/css” />
ie with single quotes around the default.
Can someone tell me where I/Geek_notes have gone wrong - thanks
I decided to use PHP and found a simple way of doing it here:
http://www.geek-notes.com/css/23/cascading-style-sheet-switcher/
But it's not quite working ... could someone help me with the syntax please
It consists of 4 parts:
1 -
Code:
<link href=”/path/<?php echo $style ?>.css” rel=”stylesheet” type=”text/css” />
[PHP]<php
if(isset($_COOK IE[’style’])){
$style=$_COOKIE[’style’];
} else {
$style=’default ’; //the name of default style file
}
?>[/PHP]
3 - [ A file called 'switch.php' consiting of the following: ]
[PHP]<?php setcookie(”styl e”, $_GET[”style”], time()+31536000 );
header(”Locatio n:”.$HTTP_SERVE R_VARS[”HTTP_REFERER”]);
?>[/PHP]
4 - [ and in the body: ]
[HTML]<a href=”/switch.php?styl e=default”>View page with Default style!</a>
<a href=”/switch.php?styl e=alternate”>Vi ew page with Alternate style!</a>[/HTML]
I named my 2 css files 'default.css' and 'alternate.css' and they are in the root directory.
When I click to select the default I get a 404 looking for:
http://test.domain.com/”switch.php?sty le=pp_style_tes t”
ie with quotes included around the argument ! (Nb - I've removed above the client's real domain name to protect the innocent ;-)
I also notice (when viewing the source) that the link has been passed by php as:
<link href=”’default’ .css” rel=”stylesheet ” type=”text/css” />
ie with single quotes around the default.
Can someone tell me where I/Geek_notes have gone wrong - thanks
Comment