The history of displaying browsing Web pages through Jquery.cookie.js is very useful _jquery

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.