473,320 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

PHP Style Switcher - Browser Problems

I posted about this a few days ago, and I got a few suggestions that
fixed part of my problem.

I am using a PHP script to switch external style sheets when the viewer
clicks on the style link. Search "Amanda H." in this group and you can
view my last post to see the original PHP and html junk. This below is
the updated link rel and the meta tags.

Before, it wouldn't refresh or change in Opera, Firefox, or IE6/Win &
IE5/Mac. The bits added on to the link rel and adding the meta tags
worked for Firefox and Opera.

In IE6/Win, the style sheet loads, but a manual refresh makes it
actually load. In IE5/Mac, the style sheets won't switch at all. I
don't know PHP very well, so I don't know what the problem could be.
Any help would be greatly appreciated. Here's the script and code:
-------------------------

<?
header('Content-Type: text/css');
// CONFIGURATION
// If you want to specify a default CSS file for users who can't handle

// cookies, replace styles.css with the filename below:

$basicsheet = "basic.css";

// CHECK IF NEW STYLESHEET IS BEING LOADED
if(isset($_GET['sheet']) OR isset($_POST['sheet'])) {

// CHECK IF FILE IS SPECIFIED IN URL
if(isset($_GET['sheet'])) { $newsheet = $_GET['sheet']; }

// CHECK IF FILE IS SPECIFIED IN FORM DATA
if(isset($_POST['sheet'])) { $newsheet = $_POST['sheet']; }

// MAKE THE USER REMEMBER WHICH STYLESHEET IS LOADED
setcookie("my_stylesheet", "$newsheet.css", 0, "/");

// SEND THE USER BACK
$ref = $_SERVER['HTTP_REFERER'];
header("Location: $ref");

} else {

// NORMAL STYLESHEET REQUEST
$mysheet = $_COOKIE['my_stylesheet'];
if($mysheet == "") { $mysheet = $basicsheet; }
include "$mysheet";
}

?>

-----------------------------------------
---end of PHP script. Then the new link header & meta tags for the
HTML file:

<link rel="stylesheet" type="text/css"
href="http://www.amandahenson.com/styleswitcher.php?<?php echo time();
?>" />

and
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />

-------------------------------------
---end. It works in most browsers, but it still has those problems
with the browsers mentioned above. Thanks ahead of time.

Amanda H.

Feb 18 '06 #1
1 1960
Hello Amanda,

I don't think there's a PHP problem. My guess is that you're running
into an issue with the COOKIE variable. Try using a session variable
instead and see if that works.

Chris S.
Implied By Design
http://www.impliedbydesign.com
Free Web Development Programs and Scripts
http://www.impliedbydesign.com/free-...e-scripts.html

Feb 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
72
by: Herbert | last post by:
I'm still relativey new to stylesheets, so I'm hoping that the way I'm going about things can be seriously improved upon, i.e . I just haven't undersood something obvious about the 'cascading'...
2
by: Christo | last post by:
Hi all! (N00b meat here-- :) Anyway, the header of this message tells you what I am seeking. The audience for my site is the lowest level tech user (because my agency is a social service...
5
by: johnny | last post by:
hi all, I would like to know if the more and more websites offering the 3 font sizes option by style switching are just following a trend or have chose the best solution by an...
9
by: Chandy | last post by:
Hi, Is there any way to apply a style that will effectively block the application of any applied or inherited styles for that object and any contained objects? E.g., CSS: P {backgro...}
7
by: T J Rogers | last post by:
Hi folks, Below is a script that I use on a site to detect the size of the browser window then automatically load an alternative stile sheet when appropriate. Its a bit clumsy, and I don't...
3
by: Daniel Greene | last post by:
Dear web writers, My lucky web visitors who are using certain browsers can select one of my style sheets out of a list, and see how my pages change "before their very eyes." Cool! But what if...
5
by: Gretsch | last post by:
After lots of problems trying to allow the visitor to switch styles using Javascript - but encountering browser incompatabilities!! I decided to use PHP and found a simple way of doing it here: ...
3
by: Dave Angel | last post by:
I have implemented the 'A list apart' styleswitcher which works great. I now have: - A permanent stylesheet - A normal contrast stylesheet - A high contrast stylesheet The switcher simply...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.