Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
刷新页面时如何通过 JavaScript 删除 cookie?我想使用 event 来做到这一点onbeforeunload。
onbeforeunload
为什么要在 cookie 有机会被发送回服务器之前删除它,这超出了我的理解,但你可以这样:
window.onbeforeunload = function(e) { document.cookie = 'cookiename=; expires=' + d.toGMTString() + ';'; };