JavaScript读写Cookie

写Cookie:
function saveUsername(theForm) {
    var expires = new Date();
    expires.setTime(expires.getTime() + 24 * 30 * 60 * 60 * 1000); // sets it for approx 30 days.
    setCookie("username",theForm.j_username.value,expires);
}


读Cookie:
if (getCookie("username") != null) {
    if (document.getElementById) {
        document.getElementById("j_username").value = getCookie("username");
        document.getElementById("j_password").focus();
    }
} else {
    document.getElementById("j_username").focus();
}

你可能感兴趣的:(JavaScript,J#)