javascript chrome 的网络工作者设置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21751775/
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-10-27 21:36:00  来源:igfitidea点击:

Web worker settings for chrome

javascriptlinuxgoogle-chrome

提问by Fisen

I have made a website which works on Firefox but not on GoogleChrome. The website uses a web worker and i get the common error message:

我创建了一个可以在 Firefox 上运行但不能在 GoogleChrome 上运行的网站。该网站使用网络工作者,我收到常见错误消息:

 "Uncaught SecurityError: Failed to create a worker: script at
    'file:///home/useraccount/School/MasterThesis/Code/physijs_worker.js' 
  cannot be accessed from origin 'null'."

I have read about this, and it is very well explained at the end of this tutorial (http://www.html5rocks.com/en/tutorials/workers/basics/), in the A word on Security section.

我已经阅读了相关内容,并且在本教程的结尾 ( http://www.html5rocks.com/en/tutorials/workers/basics/) 的“关于安全的一句话”部分进行了很好的解释。

This is my google-chrome version:

这是我的 google-chrome 版本:

Google Chrome   32.0.1700.107 (Official Build 248368) 

OS  Linux 

Blink   537.36 (@165586)

JavaScript  V8 3.22.24.17

User Agent  Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36

Command Line     /usr/bin/google-chrome 
  --allow-access-from-files --flag-switches-begin 
  --ignore-gpu-blacklist --flag-switches-end

Here we can see that the --allow-access-from-files flag truly are set. I am running it on my UBUNTU 13.10.

在这里我们可以看到 --allow-access-from-files 标志真的被设置了。我在我的 UBUNTU 13.10 上运行它。

I have also checked that the URL link are complete, as many forums suggests.

正如许多论坛所建议的那样,我还检查了 URL 链接是否完整。

There website are using Three.js and Physi.js.

有网站使用 Three.js 和 Physi.js。

It would be nice with some suggestions, on what the problem can be.

如果有一些关于问题可能是什么的建议,那就太好了。

回答by Fisen

You have to close all the windows of Chrome before opening it with --allow-file-access-from-filesflag on.

您必须先关闭 Chrome 的所有窗口,然后再打开带有--allow-file-access-from-files标记的窗口。

To open it in Ubuntu simply write google-chrome --allow-file-access-from-filesin your terminal.

要在 Ubuntu 中打开它,只需google-chrome --allow-file-access-from-files在终端中写入即可。

回答by ejmnors

IE10+ and FF can resolve this. Test it myself

IE10+ 和 FF 可以解决这个问题。自己测试一下