/*** Simple interface to cookie ***/ Something.Cookie = function (cookieName, defaultValue) { function createCookie(name, value, days) { var expires = ""; var date; if (days) { date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString(); } document.cookie = name + "=" + value + expires + "; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); var c; for (var i = 0; i < ca.length; i++) { c = ca[i]; while (c.charAt(0) === ' ') { c = c.substring(1, c.length); } if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length, c.length); } } return null; } this.read = function () { var val = readCookie(cookieName); Something.log("Read " + val + " from cookie " + cookieName); return val; }; this.readBoolean = function () { return this.read() === "true"; }; this.write = function (value) { createCookie(cookieName, value, 365); }; this.writeBoolean = function (value) { value ? this.write("true") : this.write("false"); }; if (this.read() === null) { this.write(defaultValue); } return this; };
onclick="GM_setValue("document.myform.mybox.value","true")
GM_setValue
onclick
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)