学习笔记二:学用mootools的Cookie对象

学习笔记二:学用mootools的Cookie对象

就3个方法,非常简单:get,set,remove

< head >
< title > 测试Cookie </ title >
< meta  http-equiv ="content-type"  content ="text/html; charset=gb2312" />
< script  type ="text/javascript"  src ="./js/mootools.v1.00.js?v=1" ></ script >
</ head >
< body >

< textarea  id =content  cols =80  rows =20 >
</ textarea >
< input  type =button  value ='查询'  onclick =javascript:onGet(); >
< input  type =button  value ='设置'  onclick =javascript:onSet(); >
< input  type =button  value ='清除'  onclick =javascript:onRemove(); >

< script  language ="javascript"  type ="text/javascript" >

var  name = 'mycookiename';
var  value = 'mycookievalue';

function  onGet(){
    
var  val  =  Cookie.get(name);
    
if  (val){
        $('content').value
= '查询结果:'  +  val;
    }
else {
        $('content').value
= '查询结果:未设置或过期';
    }
}
function  onSet(){
    Cookie.set(name, value, {duration: 
1 });  // duration的值为天数,默认365,0为浏览器进程结束后过期
    $('content').value = 'Cookie已设置';
}
function  onRemove(){
    Cookie.remove(name);
    $('content').value
= 'Cookie已清除';
}
</ script >

</ body >
</ html >

你可能感兴趣的:(学习笔记二:学用mootools的Cookie对象)