Jquery.cookie-----A plug-in that encapsulates a cookie. (Based on jquery)
I just need to call it.
$.cookie ("C_name", c_value,{expires:7});
You can use alert ($.cookie ("C_name")) to get the content you want to store so that the test cookie is stored;
C_name: The name of the cookie to be created;
C_value: The value or content to be stored;
Expires:7 storage date;
$.cookie ("C_name", null), or//Turn off the cookie, which can be known by the alert ($.cookie ("C_name")) to Null to know that the cookie has been cleared.
In addition, automatically stored every 5 minutes, that is, set the timer
SetInterval (function () {
$.cookie ("C_name", c_value,{expires:7});
},300000)
$ (#input). Val ($.cookie ("C_name"));//Read the cookie and the cookie is re-assigned to the original object when the page refreshes
Record it again.
JS gets the elements in the IFRAME (this is in case the IFRAME has no ID or name, etc.):
var iframe = document.getelementsbytagname (' iframe ') [0];
var ifr_document = iframe.contentWindow.document;
$ (ifr_document). Find (' #editor ');//Get the element with ID editor in the IFRAME;
Jquery.cookie Plugin source code is as follows:
Jquery.cookie = function (name, value, options) {
if (typeof value! = ' undefined ') {//name and value given, set cookie
options = Options | | {};
if (value = = = null) {
Value = ';
Options.expires =-1;
}
var expires = ';
if (Options.expires && (typeof options.expires = = ' Number ' | | options.expires.toUTCString)) {
var date;
if (typeof options.expires = = ' number ') {
Date = new Date ();
Date.settime (Date.gettime () + (Options.expires * 24 * 60 * 60 * 1000));
} else {
date = Options.expires;
}
expires = '; Expires= ' + date.toutcstring ();
}
var path = Options.path? ‘; Path= ' + (Options.path): ';
var domain = Options.domain? ‘; Domain= ' + (options.domain): ';
var secure = options.secure? ‘; Secure ': ';
Document.cookie = [name, ' = ', encodeURIComponent (value), expires, path, domain, Secure].join (");
} else {
var cookievalue = null;
if (document.cookie && document.cookie! = ") {
var cookies = Document.cookie.split (';');
for (var i = 0; i < cookies.length; i++) {
var cookie = Jquery.trim (Cookies[i]);
if (cookie.substring (0, name.length + 1) = = (name + ' = ')) {
Cookievalue = decodeURIComponent (cookie.substring (name.length + 1));
Break
}
}
}
return cookievalue;
}
};
Jquery.cookie plugin Usage Self-summary