Forum Moderators: coopster
At first I thought the following problem was caused by the stylesheets I was using, but they are css2 compliant and the xhtml1-transitional is completely compliant.
Then, I thought it might be the server I was running locally, but I tried it on a different remote server and IE still crashed.
The I thought it might be my machine, but I tried it on another machine and it crashed as well.
It seems to happen when I change the stylesheet using the stylesheet picker I wrote.
I have a bar on every page with the following code:
<span id="choosestyle">
<strong>Styles:</strong>
<a href="set_css.php?css=_css/default.css">Default</a> <span class="pipe">¦</span>
<a href="set_css.php?css=_css/proportional.css">Proportional</a> <span class="pipe">¦</span>
</span>
the set_css.php page has the folowing code:
$cacheBuster = "?c=".rand(10000,100000);
// read in get request
$css_request = $_GET["css"];
// if request not blank
if(isset($css_request) && ($css_request!= ""))
{
// if request different from current choice
if($css_request!= $_COOKIE["css_choice"])
{
setcookie("css_choice", $css_request.$cacheBuster, time()+60*60*24*1000, '/');
}
}
$location_string = "Location: ".$_SERVER["HTTP_REFERER"];
header($location_string);
<?php
// add random query to end of style sheet call to make browser
// load a new page.
$cacheBuster = "?c=".rand(10000,100000);
// get user style (has cache buster already in string), if none,
// use default
if(isset($_COOKIE["css_choice"]) && $_COOKIE["css_choice"]!="")
{
$css_choice = $_COOKIE["css_choice"];
}
else
{
$css_choice = "_css/default.css".$cacheBuster;
}
?>
<style type="text/css" title="currentStyle" media="screen">
@import "<?php echo($css_choice);?>";
</style>
<style type="text/css" title="currentStyle" media="print">
@import "_css/printer_friendly.css";
</style>
Can anyone see anything wrong with my PHP?
Thankyou.
Andrew Wilson.
I realise PHP is server side, but it does interact with the browser (headers, cookies etc).
The output is xhtml and css2 ccompliant so my thinking is that it may be something to do with PHP writing re-direct headers.
I am going to try the re-directing with javascript instead, which is annoying as I was trying to avoid any client side scripting at all.
I will post when I have tried it.
Andrew Wilson.