2016-07-26 38 views
-1

我正在從此site瞭解網絡工作人員,並遵循該示例,但我不斷收到此錯誤。這是什麼意思?我的index.html和pi.js文件都保存在我的桌面上。如何解決使用html5 web worker時的安全錯誤?

index.html:9 Uncaught SecurityError: Failed to construct 'Worker': Script at 'file:///Users/jlei/Desktop/pi.js' cannot be accessed from origin 'null'.

+0

此之前幾次有人問。 [請使用Google](https://www.google.cz/search?q=Script+at++cannot+be+accessed+from+origin+'null')。特別是我建議我在這裏回答:http://stackoverflow.com/a/33432215/607407 –

+0

[Chrome無法加載web worker]的可能重複(http://stackoverflow.com/questions/21408510/chrome-cant-負載網絡工作者) –

回答

0

我敢打賭,你不能在當地做到這一點。雖然我並不完全確定.. 您是否嘗試過LAMP或類似的甚至實際的網絡空間?

https://en.wikipedia.org/wiki/LAMP_(software_bundle)

https://sourceforge.net/projects/wampserver/

+2

我發現它只是不適用於本地chrome,除非你改變設置。或者你可以使用safari或firefox – akantoword

+0

你應該能夠在本地做到這一點,只要你使用相對路徑。唯一的例外是谷歌瀏覽器。 –