易截截图软件、单文件、免安装、纯绿色、仅160KB

javascript cookies 存、取、删除实例

<script>
//写cookies函数 作者:翟振凯
function
SetCookie(name,value)//两个参数,一个是cookie的名子,一个是值
{
    var Days = 30;
//此 cookie 将被保存 30 天
    var exp  = new Date();    //new
Date("December 31, 9998");
    exp.setTime(exp.getTime() +
Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value)
+ ";expires=" + exp.toGMTString();
}
function
getCookie(name)//取cookies函数        
{
    var arr =
document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
 
   if(arr != null) return unescape(arr[2]); return null;
}
function
delCookie(name)//删除cookie
{
    var exp = new Date();
   
exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
   
if(cval!=null) document.cookie= name +
"="+cval+";expires="+exp.toGMTString();
}
SetCookie
("xiaoqi", "3")
alert(getCookie('xiaoqi'));
</script>
一个非常实用的javascript读写Cookie函数
一个非常实用的javascript
读写Cookie函数  
function  GetCookieVal(offset)
//获得Cookie解码后的值
{
var  endstr  =  documents.cookie.indexOf  (";",  offset);
if  (endstr  ==  -1)
endstr  =  documents.cookie.length;
return  unescape(documents.cookie.substring(offset,  endstr));
}
function  SetCookie(name,  value)
//
设定Cookie值
{
var  expdate  =  new  Date();
var  argv  =  SetCookie.arguments;
var  argc  =  SetCookie.arguments.length;
var  expires  =  (argc  >  2)  ?


相关文档:

[读书笔记][JavaScript高级程序设计]

第二章:ECMAScript基础
1.当函数无明确返回值时,返回的也是值undefined
  function testFunc(){}
  alert(testFunc()==undefined);
2.typeof(null)=='object' //true,null可以解释为对象占位符
3.undefined 是声明了变量但未对其初始化时赋予该变量的值,null则用于表示尚未存在的对象。
  alert(nu ......

Javascript陷阱。。。。。。。

1.浮点运算
这可能是挫败一些对javascript不熟悉并准备执行一些数学运算的人的主要原
因.
<script>  
alert(0.02 / 0.1);  //0.19999999999999998 
  
alert(1.14 * 100);  //113.99999999999999    ;)
  
......

[翻译]High Performance JavaScript(007)

Dynamic Scopes  动态作用域
    Both the with statement and the catch clause of a try-catch statement, as well as a function containing eval_r(), are all considered to be dynamic scopes. A dynamic scope is one that exists only through execution of code and therefore cannot be det ......

[翻译]High Performance JavaScript(008)

Nested Members  嵌套成员
    Since object members may contain other members, it's not uncommon to see patterns such as window.location.href in JavaScript code. These nested members cause the JavaScript engine to go through the object member resolution process each time a dot is ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号