Ok, so I made a style switch in php, and I use it as a hidden function on my site that runs when the user enters "teema", and the modal block appears at the top of the page contents and displays available themes.
<ul> <li><a href="teema.php?teema=default" class="ajaxLink">Normaali</a></li> <li><a href="teema.php?teema=superhero" class="ajaxLink">Superhero</a></li> <li><a href="teema.php?teema=spacelab" class="ajaxLink">Spacelab</a></li> <li><a href="teema.php?teema=united" class="ajaxLink">United</a></li> <li><a href="teema.php?teema=cyborg" class="ajaxLink">Cyborg</a></li> </ul>
However, I want to change the theme without refreshing the page, so css should load in the background. Here teema.php:
<?php $style = $_GET['teema']; setcookie("teema", $style, time()+604800); if(isset($_GET['js'])) { echo $style; } else{ header("Location: ".$_SERVER['HTTP_REFERER']); } ?>
And php for the index that validates the cookie:
<?php if(!empty($_COOKIE['teema'])) $style = $_COOKIE['teema']; else $style = 'default'; ?> <link rel="stylesheet" href="css/<? echo $style;?>.css" id="theme">
How can I load the new css in the background and drag it to the old css using jQuery?
user1537415
source share