Jquery. cookie. js is used to display the history of web pages that have been browsed. jquery. cookie. js
This article uses the cookie plug-in to obtain the user's browsing history and display the user's recent browsing history on the page.
Add the following js
<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 after the cookie is injected for the first time. "This is not an array yet." handle var json1 with dots and planes; var canAdd = true; // var json1 = eval ("({sitename: 'dreamdu', sitedate: new Date (1980 , 12, 17, 12, 0, 0)}) "); if (! $. Cookie ("history") {// initialize history =$ for the first time. cookie ("history", "{title: \" "+ art_title +" \ "" + ", url: \" "+ art_url + "\"}");} else {// history already exists = $. 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
<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 shared with you through Jquery. cookie. js to demonstrate the history of Web browsing.