问题描述
(此问题与 此处 )
(This question pertains to the JS-XSL demo found here)
简短地告诉您此演示的目的是什么;它以MS Excel文件作为输入,解析数据并以纯文本格式输出数据.我下载了该软件包(zip)并在本地运行,只需通过Chrome打开html文件即可.
To briefly tell you what this demo is for; it takes a MS Excel file as input, parses the data, and outputs the data in text-only format. I downloaded the package (zip) and ran it locally, simply by opening the html file with Chrome.
问题是,我似乎无法克服以下错误:
The problem is, I just cannot seem to get over the following error:
Uncaught SecurityError: Failed to construct 'Worker': Script at 'file:///C:/Users/David/Desktop/Xlsx%20Demo/xlsworker.js' cannot be accessed from origin 'null'.
上述错误指向html文件的第34行,该行具有以下代码:
And above error points to line 34 of the html file, which has the following code:
/* I changed the file path from './xlsworker.js' to 'xlsworker.js' */
var worker = new Worker('xlsworker.js');
此演示仅包含三个文件:html文件本身和两个javascript文件,一个名为xls.js
,另一个名为xlsworker.js
.所有这三个文件都在同一目录中,并且位于同一级别.
There are only three files for this demo: the html file itself, and two javascript files, one is named xls.js
and the other xlsworker.js
. All three files are in the same directory and at the same level.
让我感到莫名其妙的是,大约几个月前,我成功运行了该演示!我无法想象我现在是否在做其他不同的事情.有见识吗?
What's rather baffling to me is, I successfully ran this same demo about a couple months ago! I cannot imagine if I am doing anything differently now. Any insight?
推荐答案
https://code.google.com/p/chromium/issues/detail?id=278883#c9
您需要一台服务器(甚至像 http://docs.python.org这样的简单服务器/2/library/simplehttpserver.html )
You need a server (even something simple like http://docs.python.org/2/library/simplehttpserver.html)
这篇关于JavaScript:“未捕获的SecurityError";在本地运行JS-XSL演示时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!