<script>
/* If there is no cookie information, the div is displayed, otherwise it is not displayed. (please test in Firefox) */
Set cookies
function Setcookie (name, value, Iday) {
var odate=new Date ();
Odate.setdate (Odate.getdate () +iday);
document.cookie=name+ ' = ' +value+ '; expires= ' +odate;
}
Read cookies
function GetCookie (name)
{
var arr=document.cookie.split (';'); Define an array
var re=new RegExp (' \\b ' +name+ ' =\\w+ '); Define a regular
var res=document.cookie.match (re); Match the selected field
if (res) {
return res[0].split (' = ') [1]; If the match succeeds, the result is returned
}
Else
{
Return '; Otherwise, return null
}
}
Delete Cookies
function Removecookie (name) {Setcookie (name, ' 1 ',-1)}//Use the Setcookie function to set the time to 1 to achieve the delete effect (no method is removed by default)
Window.onload=function ()
{
var Odiv=document.getelementbyid (' Div1 ');
if (!getcookie (' arrial '))
{
odiv.style.display= ' block ';
Setcookie (' arrial ', ' 1 ', 30); Add ' arrial ' to the cookie, ' 1 ', 30
}
};
</script>file:///home/hezhenzhen/.cache/.fr-zzlgid/%c3%90%c3%82%c3%8a%c3%96%c2%b5%c2%bc%c2%ba%c2%bd%c2% Bf%c3%8e%c2%b3%c3%8c%c3%94%c2%b4%c2%b4%c3%ba%c3%82%c3%ab/index.html
Various actions of cookies in JS