jQuery's .getJSON using local files stopped working on Firefox 3.6.13

后端 未结 1 549
陌清茗
陌清茗 2021-01-14 15:36

Suddenly, local file access using jQuery\'s .getJSON is not working for me on Firefox (3.6.13) - only.

I am aware of the problem in getting this to work in Chrome -

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-14 16:33

    I think this is due to a new security feature in Firefox: You can make local requests only to files that are in the page's directory, or in the sub-directory of the page.

    From here (emphasis mine):

    In Gecko 1.8 or earlier, any two file: URIs are considered to be same-origin. In other words, any HTML file on your local disk can read any other file on your local disk.

    Starting in Gecko 1.9, files are allowed to read only certain other files. Specifically, a file can read another file only if the parent directory of the originating file is an ancestor directory of the target file. Directories cannot be loaded this way, however.

    For example, if you have a file foo.html which accesses another file, bar.html, the load will succeed only if bar.html is either in the same directory as foo.html or in a directory contained within the same directory as foo.html.


    Footnote from PandaWood: I can confirm setting Firefox's about:config -> security.fileuri.strict_origin_policy to false, as the link you provide shows, is an immediate fix


    0 讨论(0)
提交回复
热议问题