我有以下 HTML:
<a href="/index.html" title="Click only if you are sure of your browser">
I'm warned, <strong>let me in anyway</strong></a>
有没有一种方法可以让我首先单击此链接,将一个名为“forceAccess”的 cookie 设置为“yes”值,该值会在 1 天后过期,然后才将我带到 index.html?我有以下功能,所以我想我只需要一种从上面调用它的方法:
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}