全速加载中

Cookie示例

  //caozuocookie
        var webusername = "";
        function getCookie(name)
{
 var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
 
 if(arr=document.cookie.match(reg))
 
  return unescape(arr[2]);
 else
  return null;
}
if (getCookie("username")!=null) {
 String.prototype.trim = function() {
  return this.replace(/^(\s*)|(\s*)$/g,"");
var start = getCookie("username").indexOf("usernc=", start) + 7;
var end = getCookie("username").indexOf("&", start);
webusername =decodeURI(getCookie("username").substring(start, end));
$("#username").val(webusername);

}

posted @ 2013-11-08 10:18  许鸿飞  阅读(245)  评论(0编辑  收藏  举报