|
Response.Cookies("Cookie1")("key1") = "KeyValue2"
%>
<script language="Javascript">
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<cookieArr.length; 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"));
-->
</script>
JavaScript技術:通過JAVASCRIPT讀取ASP設定的COOKIE,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。