サイトにスタイルスイッチャーを追加しました。ユーザーが最後に選択したスタイルを保存する Cookie を追加したいと考えています。私はこのコードを持っています。誰かがプロセスを案内してくれますか?
読んでくれてありがとう!
サイトのスタイルを切り替えるには、次のコードがあります。
メイン スタイルとメイン カラーを呼び出す HTML
<style type="text/css"> @import url("style.css");</style>
<link href="yellow.css" rel="stylesheet" type="text/css" title="Yellow Theme" />
次に、通常どおりスクリプトを呼び出します
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="script.js"></script>
各ボタンには次のものがあります。
<a class="colorbox colorred" href="?theme=red" title="Red Theme"><img src="red.png" width="x" height="x" /></a>
<a class="colorbox colorblack" href="?theme=black" title="Black Theme"><img src="black.png" width="x" height="x" /></a>
script.js コードは次のとおりです。
google.load("jquery", "1.5.2");
google.setOnLoadCallback(function()
{
// Color changer
$(".colorblack").click(function(){
$("link").attr("href", "black.css");
return false;
});
$(".colorred").click(function(){
$("link").attr("href", "red.css");
return false;
});
});