jquery cookie插件在ie出现bug下无效但是在firfox正常

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>测试cookie</title>
		<script type="text/javascript"
			src="<%=request.getC ontextPath()%>/Script/jquery-1.3.2.min.js"></script>
	   <script type="text/javascript"
			src="<%=request.getContextPath()%>/js/jquery.cookie.js"></script>
	   <script type="text/javascript">
           $(function(){
        	   $("#add").click(function(){
               	saveUserInfo();
                });
              });
           /**初始化页面时验证是否记住了密码**/
           $(document).ready(function() {
               if ($.cookie("rmbUser") == "true") {
                   $("#rmbUser").attr("checked", true);
                   $("#userName").val($.cookie("userName"));
                   $("#password").val($.cookie("passWord"));
               }
           });
           /**保存用户信息到cookie中**/
           function saveUserInfo() {
               if ($("#rmbUser").attr("checked") == true) {
                   var userName = $("#userName").val();
                   var passWord = $("#password").val();
                   $.cookie("rmbUser", "true", { expires: 7 }); // 存储一个带7天期限的 cookie
                   $.cookie("userName", userName, { expires: 7 }); // 存储一个带7天期限的 cookie
                   $.cookie("passWord", passWord, { expires: 7 }); // 存储一个带7天期限的 cookie
                   }else {
                    $.cookie("rmbUser", "false", { expires: -1 });
                    $.cookie("userName", '', { expires: -1 });
                    $.cookie("passWord", '', { expires: -1 });
               }
           }          
	   </script>
	</head>
	<body>
		<form action="#" name="cookie">
			用户名:
			<input name="userName" id="userName" type="text" />
			<br>
			密码:
			<input type="password" name="password" id="password" />
			<input type="checkbox" id="rmbUser" name="rmbUser"/>
			<input type="button" id="add" value="加入cookie" />
		</form>
	</body>
</html>
jQuery.cookie = function(name, value, options) {
	if (typeof value != "undefined") {
		options = options || {};
		if (value === null) {
			value = "";
			options.expires = -1;
		}
		var expires = "";
		if (options.expires
				&& (typeof options.expires == "number" || options.expires.toUTCString)) {
			var date;
			if (typeof options.expires == "number") {
				date = new Date();
				date.setTime(date.getTime()
						+ (options.expires * 24 * 60 * 60 * 1000));
			} else {
				date = options.expires;
			}
			expires = "; expires=" + date.toUTCString();
		}
		var path = options.path ? "; path=" + options.path : "";
		var domain = options.domain ? "; domain=" + options.domain : "";
		var secure = options.secure ? "; secure" : "";
		document.cookie = [ name, "=", encodeURIComponent(value), expires,
				path, domain, secure ].join("");
	} else {
		var cookieValue = null;
		if (document.cookie && document.cookie != "") {
			var cookies = document.cookie.split(";");
			for ( var i = 0; i < cookies.length; i++) {
				var cookie = jQuery.trim(cookies[i]);
				if (cookie.substring(0, name.length + 1) == (name + "=")) {
					cookieValue = decodeURIComponent(cookie
							.substring(name.length + 1));
					break;
				}
			}
		}
		return cookieValue;
	}
};           
中这一段代码明显是错误的
var cookies = document.cookie.split(";");
在js中只有
 document.cookie.split(separator, limit)这样的写法

你可能感兴趣的:(js,cookie)