一个关于正则在IE和firefox不一致的问题
写了一段JS cookie的小代码用来设置和获取cookie,代码如下。 但是在IE中father和women的值无法取得,只能获得name的值,firefox中全能获得,哪位大侠可以告知是什么原因呢?程序代码:
function setCookie(oName,oValue,oExpires,oPath,oDomain,oSecure) { var myCookie = oName + "=" + encodeURIComponent(oValue) + ";"; if(oExpires) myCookie += "expires=" + oExpires.toGMTString() + ";"; if(oPath) myCookie += "path=" + oPath + ";"; if(oDomain) myCookie += "domain=" + oDomain + ";"; if(oSecure) myCookie += "secure=" + oSecure + ";"; document.cookie = myCookie; } function getCookie(oName) { var reg = "(?:;)?" + oName + "=([^;]*);?"; var regExp = new RegExp(reg); if(regExp.test(document.cookie)) return decodeURIComponent(RegExp.$1); else return null; } setCookie("name","myname"); setCookie("father","myfather",new Date(Date.parse(11/30/2009))); setCookie("women","mywomen",new Date(Date.parse(11/4/2009))); alert(document.cookie); alert(getCookie("name")); alert(getCookie("father")); alert(getCookie("women"));