This article is to take advantage of the cookie plugin to get the user to browse the article history and display the user's most recent browsing history on the page.
Add the following JS to the page where the cookie needs to be added
<script type= "Text/javascript" src= "js/jquery.js" ></script> <script type= "Text/javascript" src= "js/" Jquery.cookie.js "></script> <script type=" Text/javascript "> $ (function () {var art_title = $ (" title ").
HTML (); var art_url = document.
URL;
var history;
var json= "[";
Json1 is the first JSON to inject the cookie after the first time, "not yet an array" vitalize the processing of Var Json1;
var canadd= true;
var json1=eval ({sitename: ' Dreamdu ', Sitedate:new Date (1980, 12, 17, 12, 0, 0)}); if (!$.cookie ("History")) {//The first time you need to initialize history = $.cookie ("History", "{title:\" "+art_title+" \ "+", url:\ "" +art_url+
"\"}");
}else {//already exists history = $.cookie ("history");
Json1 = eval ("(" +history+) ");
$ (Json1). each (function () {if (this.title==art_title) {canadd=false;
return false;
"}" if (Canadd) {$ (Json1). each (function () {JSON = json + "{\" title\ ": \" "+this.title+" \ ", \" url\ ": \" "+this.url+" \ "},";
JSON = json + "{\" title\ ": \" "+art_title+" \ ", \" url\ ": \" "+art_url+" \ "}]"; $.cookie ("History", Json,{expireS:1}); }}) </script>
Add the following JS to the Display history page
<script type= "Text/javascript" src= "js/jquery.js" ></script>
<script type= "Text/javascript" src= "Js/jquery.cookie.js" ></script>
<script type= "Text/javascript" >
$ (function () {
if ($. Cookie ("history")) {
var json = eval ("(" +$.cookie ("history") + ")");
var list = "";
$ (JSON). each (function () {
list = list + "<li><a href= '" +this.url+ "' target= ' _blank ' >" +this.title+ " </a></li> ";
alert (This.url);
})
$ ("#list"). html (list;;
}
});
</script>
The above content is small make up for everyone to share through the Jquery.cookie.js to realize the history of the Display browsing page, I hope you like.