使用 d3.json 访问本地文件不再适用于 Firefox?
Accessing local files with d3.json no longer working for firefox?
直到上周,在 firefox 中访问本地文件都没有问题,如下所示:
<!DOCTYPE html>
<meta charset="utf-8">
<title>Albers Projection</title>
<style>
path {
fill: #ccc;
stroke: #fff;
stroke-linejoin: round;
}
</style>
<svg width="960" height="500"></svg>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src ="https://d3js.org/topojson.v1.min.js"></script>
<script>
//Map obtained here:
//https://d3js.org/us-10m.v1.json
d3.json("US.json", function(error, us) {
if (error) throw error;
d3.select("svg").append("path")
.datum(topojson.feature(us, us.objects.states))
.attr("d", d3.geo.path());
});
</script>
但是,从本周开始,d3.json 步出现错误:
未捕获的异常:[对象 XMLHttpRequest]
我不认为这是由于旧版本的 D3 造成的,因为它在 V4 和 topojson.v2 中仍然存在,除了这里的错误是:
未捕获的异常:[object ProgressEvent]
我找不到任何相关信息。发生什么事了?
Local files can no longer access other files in the same directory.
更多详细信息在 security advisories
下给出
#CVE-2019-11730: Same-origin policy treats all files in a directory as having the same-origin
相关错误目前在 non-accessible,但在 bug 803143 中有相关讨论。我认为他们还没有记录开发人员可以使用哪些选项(如果有的话)继续使用本地 multi-file 文档。
您可能不得不退回到旧的 jsonp 技术或使用静态网络服务器。
对于本地开发,您可以使用 about:config -> privacy.file_unique_origin = false
覆盖此行为,但请注意,这会使您暴露于此更改旨在修复的本地数据泄露类型。
直到上周,在 firefox 中访问本地文件都没有问题,如下所示:
<!DOCTYPE html>
<meta charset="utf-8">
<title>Albers Projection</title>
<style>
path {
fill: #ccc;
stroke: #fff;
stroke-linejoin: round;
}
</style>
<svg width="960" height="500"></svg>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src ="https://d3js.org/topojson.v1.min.js"></script>
<script>
//Map obtained here:
//https://d3js.org/us-10m.v1.json
d3.json("US.json", function(error, us) {
if (error) throw error;
d3.select("svg").append("path")
.datum(topojson.feature(us, us.objects.states))
.attr("d", d3.geo.path());
});
</script>
但是,从本周开始,d3.json 步出现错误:
未捕获的异常:[对象 XMLHttpRequest]
我不认为这是由于旧版本的 D3 造成的,因为它在 V4 和 topojson.v2 中仍然存在,除了这里的错误是:
未捕获的异常:[object ProgressEvent]
我找不到任何相关信息。发生什么事了?
Local files can no longer access other files in the same directory.
更多详细信息在 security advisories
下给出#CVE-2019-11730: Same-origin policy treats all files in a directory as having the same-origin
相关错误目前在 non-accessible,但在 bug 803143 中有相关讨论。我认为他们还没有记录开发人员可以使用哪些选项(如果有的话)继续使用本地 multi-file 文档。
您可能不得不退回到旧的 jsonp 技术或使用静态网络服务器。
对于本地开发,您可以使用 about:config -> privacy.file_unique_origin = false
覆盖此行为,但请注意,这会使您暴露于此更改旨在修复的本地数据泄露类型。