ajax 谷歌浏览器 --allow-file-access-from-files 为 Chrome Beta 8 禁用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4270999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 10:56:02  来源:igfitidea点击:

Google Chrome --allow-file-access-from-files disabled for Chrome Beta 8

ajaxfilegoogle-chromelocalsame-origin-policy

提问by Alexandre

I have been developing an AJAX application using jQuery and Microsoft Seadragon technology.
I need to have access to the html5 canvas function toDataURL.

我一直在使用 jQuery 和 Microsoft Seadragon 技术开发 AJAX 应用程序。
我需要访问 html5 画布函数 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.

对于谷歌浏览器,同源规则适用于该函数,这意味着本地运行的页面(file:///在 URL 中)无法满足同源规则并抛出异常。

With Chrome 7, starting the application with --allow-file-access-from-filesoption, allows to call canvas.toDataURL()from local files.

使用 Chrome 7,使用--allow-file-access-from-files选项启动应用程序,允许canvas.toDataURL()从本地文件调用。

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.

但是,使用相同选项 ( --allow-file-access-from-files)启动 Chrome Beta 8 似乎不允许调用canvas.toDataURL()本地文件。

Does Chrome gave up on the --allow-file-access-from-filesoption or it has just been disabled since it is a Beta release and not a full release?

Chrome 是放弃了该--allow-file-access-from-files选项还是刚刚被禁用,因为它是 Beta 版本而不是完整版本?

Thanks!

谢谢!

回答by Ivo Wetzel

Looking at the issues for thisshows that the whole --allow-file-access-from-filesthing was rushed.

看看这方面的问题表明整个--allow-file-access-from-files事情都很仓促。

  1. "Firefox does it.."
  2. "How can we do it?"
  3. some time passes
  4. "Here are the patches"
  5. "Passes! On trunk wonder what happens in the next dev release"
  6. "Ahhh it's broken" "Use the command line option" "ok"
  7. "We shipped!"
  8. "WTF guys? You broke all my stuff! Why didn't you tell us earlier?"
  9. silence
  1. “Firefox 做到了……”
  2. “我们怎么办?”
  3. 过了一段时间
  4. “这是补丁”
  5. “通过!在后备箱上想知道下一个开发版本会发生什么”
  6. “啊它坏了”“使用命令行选项”“好的”
  7. “我们发货了!”
  8. “WTF家伙?你把我的东西都弄坏了!你为什么不早点告诉我们?”
  9. 安静

On to your Problem
Indeed it seems that this is something special to the beta, I'm using Chrome 8.0.552.5 devhere and --allow-file-access-from-filesworks like expected, I've also tested this with Chromium 9.0.592.0 (66889)were it also works as expected.

关于你的问题
事实上,这似乎是测试版的特殊之处,我在Chrome 8.0.552.5 dev这里使用并按--allow-file-access-from-files预期工作,我也测试过Chromium 9.0.592.0 (66889)它是否也按预期工作。

I suspect there have been some changes on the dev branch. Unfortunately, finding something on chromium's issue tracker is nearly impossible.

我怀疑 dev 分支上有一些变化。不幸的是,在 Chromium 的问题跟踪器上找到一些东西几乎是不可能的。

回答by Guillaume86

Did you close all chrome instances before opening with the command line argument? You have to do that to make that parameter work.

在使用命令行参数打开之前,您是否关闭了所有 chrome 实例?您必须这样做才能使该参数起作用。

回答by Vanuan

To summarize all answers so far.

总结到目前为止的所有答案。

Before running chrome, make sure there are no chrome processes running.

在运行 chrome 之前,请确保没有运行 chrome 进程。

Windows

视窗

-allow-file-access-from-files

(with one dash)

(一个破折号)

Linux

Linux

--allow-file-access-from-files

(with two dashes)

(有两个破折号)

回答by CommissarXiii

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.

我找到了使用 JavaScript/Flash 方法解决该问题的方法。如果 flash 是在 Local Only 安全沙箱中编译的,它就可以完全访问本地文件。使用 ExternalInterface,JavaScript 可以请求 Flash 应用程序加载文件,Flash 可以将结果传回 JavaScript。

You can find my implementation here: https://code.google.com/p/flash-loader/

你可以在这里找到我的实现:https: //code.google.com/p/flash-loader/

回答by Johnydep

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!

唤醒我的诀窍是,您必须在 HTML 代码中提供文件的绝对路径,而不仅仅是文件名。例如 file://... 而不是直接名称,即使您正在访问同一目录中的文件。它会起作用!