一个表单具有以下代码来防止多个表单提交:
function AllowNoDups() { var cookie_ls = document.cookie; if (cookie_ls.indexOf(document.location) > -1) {
alert("You've already submitted a free meter request. Thank you for your interest! ");
return false; } else { document.cookie = 'username=' + value; + 'expires=' + var now = new Date(); var time = now.getTime(); time += 3600 * 1000; now.setTime(time); document.cookie = 'username=' + value + '; expires=' + now.toGMTString() + '; path=/';; + 'path = /' document.cookie = "; path=/newform.php; expires=Sun, 1-Jan-2040 00:00:01 GMT;"; return true;};};
虽然代码有效,但我宁愿将 cookie 设置为 24 小时后过期,而不是指定 cookie 过期的日期。我将如何实现这一目标?谢谢!