В этой статье описывается, как JS использует файлы cookie для установки стилей. Поделитесь этим для вашей ссылки, следующим образом:
var styleshow = ["blackgreen", "purple"]; var path = "/"; var styleswitch = {// set style setstylesheet: function (stylename) {var i, a, main; for (i = 0; (a = document.getElementsbytagname ("link") [i]); i ++) {if (a.getattribute ("rel"). Indexof ("style")! = -1 && a.getattribute ("title")) {a.disabled = true; if (a.getattribute ("title") == stylename) {a.disabled = false; this.setcookie («стиль», стиль); }}}}}}}, // Получить текущий стиль используется GetStylesHeet: function () {var i, a; for (i = 0; (a = document.getElementsbytagname ("link") [i]); i ++) {if (a.getattribute ("rel"). Indexof ("style")! = -1 && a.getAttribute ("title") &&! }} return null; }, // Получить стиль по умолчанию getPreferredStylesHeet: function () {var i, a; for (i = 0; (a = document.getElementsbytagname ("link") [i]); i ++) {if (a.getattribute ("rel"). indexof ("style")! = -1 && a.getattribute ("rel"). indexof ("alt") -1 && a.getattribute ("rel"). }} return null; }, // getc cookie getCookie: function (name) {var cookiename = encodeuricomponent (name) + "=", cookieStart = document.cookie.indexof (cookiename), cookievalue = null; if (cookieStart> -1) {var cookieend = document.cookie.indexof (";", cookieStart); if (cookiestart == -1) {alert (-2); cookieend = document.cookie.length; } cookieValue = decodeuricomponent (document.cookie.substring (cookieStart + cookiename.length, cookieEend)); } for (var i = 0; i <styleshow.length; i ++) {if (cookievalue == styleshow [i]) {alert (styleshow [i]); вернуть стили »[i]; }} return styleshow [0]; }, // Сгенерировать cookie // Имя cookie Имя // Значение // истекает время истечения срока // Путь SetCookie: function (имя, значение, истечение, путь, домен, безопасный) {var cookietext = encodeuricomponent (name) + "=" + encodeuricomponent (value) + ";"; if (истекает exanceof date) {cookietext + = "expires =" + истекает.togmtString (); } if (path) {cookietext + = "; path =" + path; } if (domain) {cookietext + = "; domain =" + domain; } if (secure) {cookietext += "; secure"; } document.cookie = cookietext; }, // сбросить cookie unsetcookie: function (имя, путь, домен, безопасный) {this.set (name, ", новая дата (0), path, domain, screen); }};For more information about JavaScript related content, please check out the topics of this site: "Summary of JSON operation techniques in JavaScript", "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm techniques", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript Структуры данных и методы алгоритма »,« Сводка алгоритмов и методов обхода JavaScript »и« Сводка использования математических операций JavaScript ».
Я надеюсь, что эта статья будет полезна для каждого программирования JavaScript.