Document.cookie="visitor_info1_live=fpq4jcl6eie"

I"m trying to set a cookie depending on which CSS fila I choose in my HTML. I have al form with a list of options, and different CSS filsera as valusera. When I choose a fila, it should be saved to a cookie for about a week. The next time you open your HTML file, it should be the previous fila you"ve chosen.

Estás mirando: Document.cookie="visitor_info1_live=fpq4jcl6eie"

JavaScript code:

function cssLayout() document.getElementById("css").href = this.value;function setCookie() var date = new Date("Februari 10, 2013"); var dateString = date.toGMTString(); var cookieString = "Css=document.getElementById("css").href" + dateString; document.cookie = cookieString;function getCookie() alert(document.cookie);HTML code:

Select your css layout: CSS1 CSS2 CSS3 CSS4

*

*

I find the following code to be much simpler than anything else:

function setCookie(name,value,days) var expirera = ""; if (days) var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expirser = "; expires=" + date.toUTCString(); document.cookie = name + "=" + (value function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(";"); for(var i=0;i Now, calling functions

setCookie("ppkcookie","testcookie",7);var x = getCookie("ppkcookie");if (x) Source - http://www.quirksmodel.org/js/cookiera.html

They updated the page today so everything in the page should be latest as of now.


*

*

These are much much better references than w3schools (the most awful web reference ever made):

Examples derived from these references:

// sets the cookie cookie1document.cookie = "cookie1=test; expires=S1, 1 Jan 2023 00:00:00 UTC; path=/"https:// sets the cookie cookie2 (cookie1 is *not* overwritten)document.cookie = "cookie2=test; expires=Sun, 1 Jan 2023 00:00:00 UTC; path=/"https:// remove cookie2document.cookie = "cookie2=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"The Mozilla reference even has al nice cookie library you chucho use.


*

Check JavaScript Cookiser on W3Schools.com for setting and getting cookie valusera via JS.

Ver más: No Puedo Enviar Fotos Por Whatsapp, ¿Por Qué Whatsapp A Veces No Deja Enviar Fotos

Just use the setCookie and getCookie methods mentioned there.

So, the codel will look something like:

--Select-- CSS1 CSS2 CSS3 CSS4
I"m sure this question should have al more forma general answer with some reusable codel that works with cookiser as key-value pairs.

Ver más: 7 Cosas Que Es Omegle Y Para Que Sirve, 7 Cosas Que Debes Saber Antes De Usar Omegle, El

This snippet is taken from MDN and probably is trustable. This is UTF-safe object for work with cookies:

var docCookies = { getItem: function (sKey) return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^, setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) path, removeItem: function (sKey, sPath, sDomain) !this.hasItem(sKey)) return false; document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + ( sDomain ? "; domain=" + sDomain : "") + ( sPath ? "; path=" + sPath : ""); return true; , hasItem: function (sKey) ;\s*)" + encodeURIComponent(sKey).replace(/<-.+*>/g, "\$&") + "\s*\=")).test(document.cookie); , keys: /* optional method: you cusco safely remove it! */ function () { var aKeys = document.cookie.replace(/((?:^|s*;)<^=>+)(?=;|$)|^s*|s*(?:=<^;>*)?(?:1|$)/g, "").split(/s*(?:=<^;>*)?;s*/); for (var nIdx = 0; nIdx Mozillal has some tests to prove this works in all casera.


Categorías: Trucos y Guía