String.prototype.get=function(name){varreg=newRegExp("(^|&|\\?)"+na" />

通过JAVASCRIPT读取ASP设定的COOKIE_2

标签:业务范围    日期:2019-03-09 12:05    录入:美娱国际平台注册    浏览:

  

[通过JAVASCRIPT读取ASP设定的COOKIE]通过JAVASCRIPT读取ASP设定的COOKIE_2

   代码如下:
  
<%  
Response.Cookies("Cookie1")("key1") = "KeyValue2"  
%>  
  
  
  
  
String.prototype.get = function(name){  
var reg = new RegExp("(^|&|\\?)" + name + "=([^&]*)(&|$)"),r;  
if(r=this.match(reg))  
return unescape(r[2]);  
return null;  
}  
  
  
//获取并返回 cookie 值  
//不区分 cookieName 的大小写  
//dfltValue 为默认返回值  
//不考虑子键  
function RequestCookies(cookieName)  
{  
var lowerCookieName = cookieName.toLowerCase();  
var cookieStr = document.cookie;  
  
if (cookieStr == "")return "";  
  
  
var cookieArr = cookieStr.split("; ");  
var pos = -1;  
for (var i=0; i pos = cookieArr[i].indexOf("=");  
if (pos > 0) {  
if (cookieArr[i].substring(0, pos).toLowerCase() == lowerCookieName)  
{  
return unescape(cookieArr[i].substring(pos+1, cookieArr[i].length));  
美娱国际娱乐 }  
}  
}  
  
return "";  
}  
  
document.write("读取名称为 ab 的 cookie..." + RequestCookies("Cookie1").get("key1"));  
-->  
  
  

★★★小编:美娱国际 整理文章,欢迎大家转载 ★★★
相关文章阅读
点击右上角的分享按钮即可收藏美娱国际平台注册 随时随地与好友一起分享精彩内容噢