[转]检查浏览器是否支持javascript和cookie
转自:http://blog.csdn.net/zealVampire/archive/2008/10/31/3194159.aspx
1. JavaScript
- <noscript>
- <font color=red>Sorry, your browser does not support JavaScript!</font>
- </noscript>
2. cookie
转自一个叫MEZI CSDN一帖找到的
- function setCookie(name,value,duration)
- {
- var exp = new Date();
- exp.setTime(exp.getTime() + duration);
- document.cookie = name + "="+ escape(value) +";expires="+ exp.toGMTString();
- }
- function getCookie(name)
- {
- 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!=null) document.cookie=name +"="+cval+";expires="+exp.toGMTString();
- }
- function isCookieEnable(){
- if (!window.navigator.cookieEnabled) return false;
- var key='supportCookie';
- setCookie(key,key,60000);
- var v = getCookie(key);
- if (v==key) {
- delCookie(key);
- return true;
- }
- return false;
- }