如何使用JavaScript清除所有cookie?
要使用JavaScript清除所有cookie,请将到期日期设置为过去的某个时间。
示例
您可以尝试运行以下代码清除所有cookie-
<html>
<head>
<script>
<!--
function WriteCookie() {
var now = new Date();
now.setMonth( now.getMonth() - 1 );
cookievalue = escape(document.myform.customer.value) + ";"
document.cookie="name=" + cookievalue;
document.cookie = "expires=" + now.toUTCString() + ";"
document.write("Setting Cookies : " + "name=" + cookievalue );
}
//-->
</script>
</head>
<body>
<form name="myform" action="">
Enter name: <input type="text" name="customer"/>
<input type="button" value="Set Cookie" onclick="WriteCookie()"/>
</form>
</body>
</html>热门推荐
10 冬日问候祝福语大全简短
11 女儿蛋糕祝福语简短精辟
12 9字祝福语简短创意
13 客户祝福语事业文案简短
14 妈咪跟我生日祝福语简短
15 生完孩子祝福语简短
16 中考祝福语妹妹文案简短
17 考进高中祝福语简短
18 惊喜自己的祝福语简短