1.
function check(){ window.navigator.cookieEnabled)
return true;
else{
alert("瀏覽器設定錯誤,Cookie 🎜>
2.
複製程式碼
alert('不支援');
} alert('不支援');
else
{
alert('支援');
}
function SetCookie(name,value)//兩個參數,一個是cookie的名子,一個是值 >{
var Days = 30; //此cookie 將會保存30 天
var exp = new Date(); //new Date("December 31, 9998") 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)//刪除> var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval! name "=" cval ";expires=" exp.toGMTString();
}
3.
複製程式碼
複製程式碼
var cookieEnabled=(navigator.cookieEnabled)? true : false
//判斷cookie是否開啟🎜>
器不是ie4 或ns6
if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){
document.cookie="testcookie"
cookiepookiePabled=testument.cookie="testcookie"
cookieookieabled=testumEnablec=)? true : false
document.cookie="" //erase dummy value
}