Javascript文件.Cookie删除“名称”;和“;value"
Javascript document.cookie remove "name" and "value"
在我的Javascript中,我有一个cookie的几个名称和值:
"Token=23432112233299; sessionuid=abce32343234"
当我从服务器下载一个文件时,添加一个Cookie,这样新的文档Cookie将看起来:
"Token=23432112233299; sessionuid=abce32343234; fileDownload=true"
如何从cookie
中删除fileDownload
的名称和值并更新document.cookie?
更新:
这是我到目前为止所做的代码,但它不工作:
if (document.cookie.indexOf("fileDownload=true;") != -1) {
document.cookie = document.cookie.replace("fileDownload=true;", "");
} else {
document.cookie = document.cookie.replace("fileDownload=true", "");
}
将expires参数更改为过期日期。
文档。cookie = 'fileDownload =;到期= 1";
var cookieData = "fileDownload=; path=/" +"; expires=" + new Date(0).toUTCString() + ";";
if (null) cookieData += " domain=null;";
document.cookie = cookieData;
相关文章:
- 铬:“;未捕获的语法错误:意外的标记:"
- 可以设置“;文件名"发生错误时显示的内联脚本标记的
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 在ember/handlers中使用value和valueBinding有什么区别
- 使用“+="操作人员
- //而不是在src=“”上使用http://"属性
- "未捕获的语法错误:意外的标记}"
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- "实例范围”;TypeScript类的getter/setter
- Javascript复选框函数:;缺少:在属性id之后"
- "“;变量未引用正确的对象
- "日期“;AJAX请求返回的类型值未定义
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- "工具提示"jQuery插件坏了
- "锻造;React中的表达式
- HTML select.value in"旧浏览器"
- value=" someevalue& quot;有什么区别?并在html中设置(value," s
- <textarea onclick=“;this.value;this.select()">?这是什么