•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 373,915 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,615 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 3848 | Replies: 7
![]() |
•
•
Join Date: Mar 2003
Posts: 11
Reputation:
Rep Power: 6
Solved Threads: 0
Hi,
I know CSS and XHTML like the back of my hand, but am wondering how you can allow a visitor to a site change the CSS file used (like in TechTalk flat / 3d), but without having the registering system?
I would use it either from a pull down menu or a separate list of links.
Thanks In Advance
I know CSS and XHTML like the back of my hand, but am wondering how you can allow a visitor to a site change the CSS file used (like in TechTalk flat / 3d), but without having the registering system?
I would use it either from a pull down menu or a separate list of links.
Thanks In Advance
Regards,
Matt :D
Matt :D
•
•
Join Date: Feb 2002
Location: Lawn Guylen, NY
Posts: 10,873
Reputation:
Rep Power: 32
Solved Threads: 109
#2
Mar 7th, 2003
The only way that I could think of doing this is via a cookie which expires ... or by using sessions which keep track of the style in use (if the site has some sort of backend web dev language).
This site is based off of phpBB forum software, and there is actually a mod/hack available @ phpBB which allows non-registered guests to change the template based on a cookie. However, the hack is very phpBB specific. You might want to take a look at it to see how it's implemented, but I doubt it would be much help.
This site is based off of phpBB forum software, and there is actually a mod/hack available @ phpBB which allows non-registered guests to change the template based on a cookie. However, the hack is very phpBB specific. You might want to take a look at it to see how it's implemented, but I doubt it would be much help.
Dani the Computer Science Gal
Do you run a computer-related website? Feature it in our niche link directory!
Do you run a computer-related website? Feature it in our niche link directory!
•
•
Join Date: Feb 2002
Location: Long Island, NY
Posts: 1,134
Reputation:
Rep Power: 12
Solved Threads: 2
#3
Mar 8th, 2003
Like a cscgal said, set up a cookie. I'm assuming that you don't have an application server, just a regular web server like Apache. You can make a cookie in JavaScript then read it and set up whichever style they choose.
_.:: my websites ::._
blog @ www.samaru.net * engi No Jutsu @ www.narutorp.net * portfolio @ shinylight.com
deviantART: inscissor
blog @ www.samaru.net * engi No Jutsu @ www.narutorp.net * portfolio @ shinylight.com
deviantART: inscissor
•
•
Join Date: May 2003
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
#4
May 6th, 2003
if you're going to use PHP for this without any backend DB support (ie mysql, or postgrep) you can use something like
// Set it all up
$cookie_name = 'cookiename'; // Name the cookie
$css = 'layouta'; // Cookie Value
$days = 365; // Cookie Life
$cookie_time = time() + ( (3600*24) * $days);
setcookie ($cookie_name, $css, $cookie_time);
// Suck it all out
$cookie_name = 'cookiename';
$css = $HTTP_COOKIE_VARS[$cookie_name];
YOu should obviously do some kind of check at the top of your file to see if it the cookie exists, if not, then install it with a default profile to start ... and then update it accordingly when the user selects the setup he or wants.
Hope that helps!
// Set it all up
$cookie_name = 'cookiename'; // Name the cookie
$css = 'layouta'; // Cookie Value
$days = 365; // Cookie Life
$cookie_time = time() + ( (3600*24) * $days);
setcookie ($cookie_name, $css, $cookie_time);
// Suck it all out
$cookie_name = 'cookiename';
$css = $HTTP_COOKIE_VARS[$cookie_name];
YOu should obviously do some kind of check at the top of your file to see if it the cookie exists, if not, then install it with a default profile to start ... and then update it accordingly when the user selects the setup he or wants.
Hope that helps!
Titan Networks Ltd.
BSD Addict.
BSD Addict.
hi, I know this is a late post, but I just did the same and it works well..
This code, unfortunately, is javacsript, but there is a php code for it.
basically, get your different css styles ready, then
post this in your <head>
[edit] script removed and added as attachment. peterska2. [/edit]
is this what you want?
You can turn the links into a drop down nav easy. Mine are just links.
Hope it helps...
This code, unfortunately, is javacsript, but there is a php code for it.
basically, get your different css styles ready, then
post this in your <head>
[edit] script removed and added as attachment. peterska2. [/edit]
is this what you want?
You can turn the links into a drop down nav easy. Mine are just links.
Hope it helps...
Last edited by peterska2 : Nov 26th, 2003 at 8:06 am.
•
•
Join Date: Nov 2003
Location: Toronto, Canada
Posts: 354
Reputation:
Rep Power: 6
Solved Threads: 5
Maybe use PHP instead for this instead 
You can learn about the setcookie() function in PHP by going here: http://ca.php.net/manual/en/function.setcookie.php
So, when a user first visits your site, have an option somewhere where they can select which style/CSS they want (using a dropdown maybe) and then when they submit that, then it will drop the cookie on their computer. So the next time they visit, the website checks their cookie to see what style they prefer to use
Let me know if you need some more info!

You can learn about the setcookie() function in PHP by going here: http://ca.php.net/manual/en/function.setcookie.php
So, when a user first visits your site, have an option somewhere where they can select which style/CSS they want (using a dropdown maybe) and then when they submit that, then it will drop the cookie on their computer. So the next time they visit, the website checks their cookie to see what style they prefer to use

Let me know if you need some more info!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb HTML and CSS Marketplace
- Layout Tables to CSS (HTML and CSS)
- CSS center vertical (HTML and CSS)
Other Threads in the HTML and CSS Forum
- Previous Thread: W3C Validation
- Next Thread: mozilla & dynamic width iframe



Linear Mode