Firefox 3 中的 getImageData 导致 NS_ERROR_DOM_SECURITY_ERR
我正在尝试开发一个在 Firefox 3 的 javascript 中使用 getImageData 的应用程序,但在 getImageData 调用中收到“NS_ERROR_DOM_SECURITY_ERR
”。 javascript 和图像当前均由硬盘驱动器提供服务,这显然是一种安全违规? 当它上线时,它们都将由同一个域提供服务,所以这不会成为问题,但同时我该如何开发呢?
I'm trying to develop an application that will use getImageData in javascript in Firefox 3, but I am getting a "NS_ERROR_DOM_SECURITY_ERR
" on the getImageData call. The javascript and the image are both currently being served from by hard drive, which is apparently a security violation? When this is live they will both be served from the same domain, so it won't be a problem, but how can I develop in the meantime?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以告诉浏览器关闭。 该解决方案是好还是坏取决于您的具体情况。 我将其包装在尝试中,因此如果不是问题,则不会显示安全对话框。
You can tell the browser to bug off. The solution is better or worse depending on your circumstances. I wrap it in a try so no security dialog will be presented if it's not an issue.
您可以尝试安装本地网络服务器,例如 Apache(在 unix 上)或 IIS(在 Windows 上)。 这最终将为您提供与网络相关的内容的最佳本地测试平台,因为正如您所发现的,浏览器处理文件系统中的文件与网络服务器提供的内容完全不同。
You could try installing a local webserver such as Apache (on unix) or IIS (on Windows). That will ultimately give you the best local test bench for web-related stuff, because as you have found out browsers treat files from the filesystem quite differently than content served from a webserver.
在 Firefox 中,在地址栏中输入“about:config”。 然后使用搜索字段搜索“security.fileuri.strict_origin_policy”。 双击此项将其设置为“false”。
In Firefox, type "about:config" into your address bar. Then use the search field to search for "security.fileuri.strict_origin_policy". Double click this to set it to "false".
我在 FireFox 11.0 中使用
getImageData
时遇到了同样的问题...我的所有文件和代码都在我的服务器上,我的本地计算机上没有任何内容。
我想这也许可以帮助那些和我有同样问题的人。
看起来 Firefox 将
其视为不同的域,
所以当用户不输入时,我使用
.htaccess
添加www.
现在它工作正常并且不不再显示
NS_ERROR_DOM_SECURITY_ERR
。I had the same problem while using
getImageData
in FireFox 11.0 ...All my files and codes were on my server and there was nothing on my local computer.
I thought maybe this helps someone who has the same problem as me.
It looks like that Firefox treats
as a different domain from
So I used
.htaccess
to addwww.
when users don't type it inNow it works fine and doesn't show
NS_ERROR_DOM_SECURITY_ERR
anymore.