当我尝试设置 cookie 时,未捕获错误:SECURITY_ERR:DOM 异常 18
当我尝试使用 this jQuery 设置 cookie 时,我在 Chrome 的开发人员工具窗口中收到以下错误插件:
未捕获的错误:SECURITY_ERR:DOM 异常 18
此错误是什么意思以及如何修复它?当我使用 this jQuery 插件时,我遇到了同样的错误。
I get the following error in Chrome's developer tools window when I try to set a cookie using this jQuery plugin:
Uncaught Error: SECURITY_ERR: DOM Exception 18
What does this error mean and how can I fix it? I get the same error when I use this jQuery plugin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
您很可能通过
file://
URI 方案在本地文件上使用此功能,该方案无法设置 cookie。将其放在本地服务器上,以便您可以使用http://localhost
。You're most likely using this on a local file over the
file://
URI scheme, which cannot have cookies set. Put it on a local server so you can usehttp://localhost
.我在本地开发HTML5时也遇到了这个问题。
我遇到了图像和 getImageData 函数的问题。
最后,我发现可以使用 --allow-file-access-from-file 命令开关启动 chrome,从而摆脱这种保护安全性。
唯一的问题是,它使您的浏览器安全性降低,并且您不能让一个 chrome 实例打开该标志,而另一个 chrome 实例没有该标志。
I also had this issue while developping on HTML5 in local.
I had issues with images and getImageData function.
Finally, I discovered one can launch chrome with the --allow-file-access-from-file command switch, that get rid of this protection security.
The only thing is that it makes your browser less safe, and you can't have one chrome instance with the flag on and another without the flag.
您还可以通过将图像替换为其内联 Base64 表示形式来“修复”此问题:
<代码>
Useful, when you do not intend to publish the page on the web, but instead use it on local machines only.
You can also "fix" this by replacing the image with its inline Base64 representation:
Useful, when you do not intend to publish the page on the web, but instead use it on local machines only.
面对使用 Javascript webworkers 的相同情况。不幸的是,Chrome 不允许访问存储在本地文件中的 JavaScript Worker。
下面使用本地存储的一种解决方法是使用
--allow-file-access-from-files
(末尾带有s
)运行 Chrome,但只有一个允许使用 Chrome 实例,这对我来说不太方便。因此,我使用 Chrome Canary,并允许文件访问。顺便说一句,在 Firefox 中不存在这样的问题。
Faced with the same situation playing with Javascript webworkers. Unfortunately Chrome doesn't allow to access javascript workers stored in a local file.
One kind of workaround below using a local storage is to running Chrome with
--allow-file-access-from-files
(withs
at the end), but only one instance of Chrome is allowed, which is not too convenient for me. For this reason i'm using Chrome Canary, with file access allowed.BTW in Firefox there is no such an issue.
如果您尝试使用数据 URI 方案创建 Web Worker,则会弹出此错误。
根据标准,这是不允许的: http ://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#dom-worker
This error pops up, if you try to create a web worker with data URI scheme.
It's not allowed according to the standard: http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html#dom-worker
我在使用历史 API 时遇到了这个问题。
即使使用本地服务器 (localhost),您也需要将“http://”添加到 URL,以便获得类似于以下内容的内容:
I had this issue when using the history API.
Even with a local server (localhost), you want to add 'http://' to your URL so that you have something similar to:
我对
--allow-file-access-from-files
解决方案并不完全满意,因为我使用 Chrome 作为我的主要浏览器,并且对这次违规并不太满意开放。现在我正在使用 Canary(chrome beta 版本)进行开发,并打开该标志。
而我真正的博客的 Chrome 版本:这两个浏览器不共享标志!
I wasn't completely happy by the
--allow-file-access-from-files
solution, because I'm using Chrome as my primary browser, and wasn't really happy with this breach I was opening.Now I'm using Canary ( the chrome beta version ) for my development with the flag on.
And the mere Chrome version for my real blogging : the two browser don't share the flag !
如果在获得许可之前使用新的(目前仅限 webkit)通知功能,也可能会收到此错误。
首次运行:
稍后运行:
请求权限功能需要由用户引发的事件触发,否则不会显示。
One can also receive this error if using the new (so far webkit only) notification feature before getting permission.
First run:
Later run:
The request permission functions needs to be triggered from an event caused by the user, otherwise it won't be displayed.
当使用 ASP.NET MVC 返回带有重载的 FileResult 时,我在移动 safari 中遇到了该错误,该重载返回的文件名与原始文件名不同。因此,
在 mobile safari 中会出现错误,而 as 则
不会。
我什至不记得为什么我认为我正在做的事情是个好主意。我想是想变得聪明吧。
I was been getting that error in mobile safari when using ASP.NET MVC to return a FileResult with the overload that returns a file with a different file name than the original. So,
would give the error in mobile safari, where as
would not.
I don't even remember why I thought what I was doing was a good idea. Trying to be clever I guess.