原理 就是每次瀏覽產品時候存個cookie
在產品詳細頁面
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../js/history.js"></script>
<script type="text/javascript" src="../js/jquery.cookie.js"></script>
<script type="text/javascript" src="..//public/jquery.json.js"></script>
<script type="text/javascript">
//存儲一個記錄
setHistory("goodshistory", { "keyname": "GoodsId", "data": { "GoodsName": "{%@rowgoods[EnglishName]%}", "GoodsId": "{%@rowgoods[GoodsId]%}", "CAS": "{%@rowgoods[CAS]%}" } });
讀取的地方
<ul id="history">
<li><a style="color:#444;" href="{%~productview.html&gid=a['GoodsId']%}"><span>a['CAS']</span> a['GoodsName']</a></li>
</ul>
<script type="text/javascript">historylist("history", "history", "goodshistory", 6)</script>