“NS_ERROR_DOM_BAD_URI: Access to restricted URI denied”

不羁的心 提交于 2019-12-09 02:19:49

问题


I have an html-file with several d3-graphs directly written in script tags into it. When I outsource one of the graphs into an external js file I get this message "NS_ERROR_DOM_BAD_URI: Access to restricted URI denied". If I delete the code with d3.json where it reads a local json file the error disappears. But it has to be possible to load a json file in an external js which is embedded into an html, right?

d3.json("forcetree.json", function(json) {
root = json;
update();
});

回答1:


I was having the same error and the solution is to have your index.html, script.js and data.json in the same directory.




回答2:


Specify your .json file relative to your .html file root

Ex:

d3.json("js/forcetree.json", function(json) {
  root = json;
  update();
});



回答3:


I have the same problem and i solve using the json file path like this:

d3.json("file:///C:/path/...../js/forcetree.json", function(json) {
  root = json;
  update();
});

if i access this path from browser the file open the URL.




回答4:


I solved this issue by moving the JSON file to a subdirectory of the directory containing my html file.

BROKEN:

www/
  code/
    hello.html    # refers to ../data/hello.json
  data/
    hello.json

WORKING:

www/
  hello.html      # refers to data/hello.json
  data/
    hello.json


来源:https://stackoverflow.com/questions/17340482/ns-error-dom-bad-uri-access-to-restricted-uri-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!