Here is a thread that I found in a Google search:
http://www.daniweb.com/forums/thread62265.html It gives code that will generate a style sheet link on the home page. Can anyone add additional code that could be added to internal pages to pick up on the homepage selection and use it on the rest of the internal pages. I would be great if cookies could be avoided as some users don't like them and a site then would not look great. Here is a link to a simple two page site that uses cookies, but it has issues if cookies are disallowed:
Many Thanks.
printman55 0 Light Poster
Recommended Answers
Jump to Post— Member #120589JS can write cookies - but you don't want this.
php/other server side languages can use querystrings (url parameters) to propagate the chosen css sheet.However, the best way - if you don't want to use cookies would be to use session variables.
php example:
Link list
…
Jump to Post— Member #120589OK - php or js can select a random stylesheet. Using sessions - you can propagate the css along the pages.
At the very top of every page:
<?php session_start(); if(!isset($_SESSION['css'])){ $css_list = array("colourful.css","darkness.css","bright.css"); $int = mt_rand(0, count($css_list)-1); $_SESSION['css'] = $css_list[$int]; } ?>Then in your …
Jump to Post— Member #120589Yes it does, so you've probably got different code to me:
Try this - I've sectioned the include file and javascript -
Will upload the zip file for the example...//EDIT - here we go
…
Jump to Post— Member #120589In the css_checker.php/css_checker2.php files, do this:
$css_list = array("bright.css","dark.css","color.css");default.css will not be chosen if cookies available.
No need to change the js. Just keep the default.css in there. It doesn't do anything with the php array. JS is run after the server sends the info …
Jump to Post— Member #120589reboot will probably clear session data. IE is a pig. We can probably use a line to prevent default.css from being called by php. Like this:
session_start(); if(!isset($_SESSION['css']) || $_SESSION['css'] == 'default.css'){ $css_list = array("bright.css","dark.css","color.css"); $int = mt_rand(0, count($css_list)-1); $_SESSION['css'] = $css_list[$int]; } $css_file = $_SESSION['css'];If …
All 28 Replies
Member #120589
printman55 0 Light Poster
Member #120589
printman55 0 Light Poster
Member #120589
printman55 0 Light Poster
Member #120589
Member #120589
printman55 0 Light Poster
Member #120589
Member #120589
printman55 0 Light Poster
Member #120589
printman55 0 Light Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
Member #120589
printman55 0 Light Poster
printman55 0 Light Poster
Member #120589
Member #120589
printman55 0 Light Poster
Member #120589
printman55 0 Light Poster
Member #120589
printman55 0 Light Poster
Member #120589
printman55 commented: He was very helpful in helping to develop the code I needed. Ardav is a real asset to the community. +1
printman55 0 Light Poster
Member #120589
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.