Chrome Beta 8 禁用 Google Chrome --allow-file-access-from-files
我一直在使用 jQuery 和 Microsoft Seadragon 技术开发 AJAX 应用程序。
我需要访问 html5 canvas 函数 toDataURL。
对于 Google Chrome,同源规则适用于该函数,这意味着本地运行的页面(URL 中带有 file:///
)无法满足同源规则并引发异常。
在 Chrome 7 中,使用 --allow-file-access-from-files
选项启动应用程序,允许从本地文件调用 canvas.toDataURL()
。
但是,似乎使用相同选项 (--allow-file-access-from-files
) 启动 Chrome Beta 8 不允许调用 canvas.toDataURL()
在本地文件上。
Chrome 是否放弃了 --allow-file-access-from-files
选项,或者它刚刚被禁用,因为它是 Beta 版本而不是完整版本?
谢谢!
I have been developing an AJAX application using jQuery and Microsoft Seadragon technology.
I need to have access to the html5 canvas function toDataURL.
With Google Chrome, the same origin rule applies to this function which means that a page run locally (with the file:///
in the URL) failed to satisfy the same origin rule and an exception is thrown.
With Chrome 7, starting the application with --allow-file-access-from-files
option, allows to call canvas.toDataURL()
from local files.
However, it seems that starting the Chrome Beta 8 with the same option (--allow-file-access-from-files
) does not allow the call canvas.toDataURL()
on the local file.
Does Chrome gave up on the --allow-file-access-from-files
option or it has just been disabled since it is a Beta release and not a full release?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
查看此问题表明整个
--allow-file-access- from-files
事情很仓促。解决你的问题
事实上,这似乎对测试版来说很特别,我在这里使用
Chrome 8.0.552.5 dev
,--allow-file-access-from-files
的工作原理如下正如预期的那样,我还使用Chromium 9.0.592.0 (66889)
对此进行了测试,它是否也按预期工作。我怀疑 dev 分支发生了一些变化。不幸的是,在 Chromium 的问题跟踪器上找到一些东西几乎是不可能的。
Looking at the issues for this shows that the whole
--allow-file-access-from-files
thing was rushed.On to your Problem
Indeed it seems that this is something special to the beta, I'm using
Chrome 8.0.552.5 dev
here and--allow-file-access-from-files
works like expected, I've also tested this withChromium 9.0.592.0 (66889)
were it also works as expected.I suspect there have been some changes on the dev branch. Unfortunately, finding something on chromium's issue tracker is nearly impossible.
在使用命令行参数打开之前,您是否关闭了所有 chrome 实例?您必须这样做才能使该参数起作用。
Did you close all chrome instances before opening with the command line argument? You have to do that to make that parameter work.
总结到目前为止的所有答案。
在运行 chrome 之前,请确保没有正在运行的 chrome 进程。
Windows
(带有一个破折号)
Linux
(带有两个破折号)
To summarize all answers so far.
Before running chrome, make sure there are no chrome processes running.
Windows
(with one dash)
Linux
(with two dashes)
我找到了使用 JavaScript/Flash 方法解决该问题的方法。如果 flash 在 Local Only 安全沙箱中编译,则它具有对本地文件的完全访问权限。使用ExternalInterface,JavaScript可以请求Flash应用程序加载文件,并且Flash可以将结果传递回JavaScript。
您可以在这里找到我的实现:https://code.google.com/p/flash-loader /
I've found a way around the issue using a JavaScript/Flash approach. If flash is compiled in the Local Only security sandbox, it has full access to local files. Using ExternalInterface, JavaScript can request a Flash Application to load a file, and Flash can pass the result back to JavaScript.
You can find my implementation here: https://code.google.com/p/flash-loader/
让我醒悟的技巧是,您必须在 HTML 代码中提供文件的绝对路径,而不仅仅是文件名。例如 file://... 而不是直接名称,即使您正在访问同一目录中的文件。它会起作用的!
The trick that woked for me is that you have to give the absolute path of the file and not just file name in your HTML code. e.g file://... instead of direct name even though you are accessing the file in the same directory. It will work!