青春有我
您可以使用localStorage. function onBodyClick() { var lastOpened = localStorage.getItem('body-opened'); // You can use another identifier instead of 'body-opened' if (lastOpened && new Date(lastOpened).toDateString() === new Date().toDateString()) { return true; } else { localStorage.setItem('body-opened', new Date().toDateString()); document.location.href = 'test.htm'; } }