【问题标题】:XMLHttpRequest cannot load local destop file in htmlXMLHttpRequest 无法在 html 中加载本地桌面文件
【发布时间】:2013-07-15 15:28:57
【问题描述】:

我的桌面文件夹中有一个 json 文件,我尝试访问我的 html 文件,但出现以下错误。

XMLHttpRequest 无法加载文件://localhost/Users/p41technologies/Desktop/Json%20in%20Html/json-data.json。 Access-Control-Allow-Origin 不允许 Origin null。

我什至尝试过,

open -a "Google Chrome" --args --allow-files-access-from-files

open -a "Google Chrome" --disable-web-security

但它没有用。我仍然得到同样的错误。 为什么会发生以及如何解决。

【问题讨论】:

    标签: javascript html macos


    【解决方案1】:

    您遇到的安全功能应该是防止恶意脚本从本地文件系统中读取。

    您查看过html5 file/filereader api 吗?有一个tutorial with working demos。你也可以看看here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-04
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 2016-09-10
      • 1970-01-01
      • 2019-02-12
      相关资源
      最近更新 更多