【发布时间】:2017-03-14 13:33:13
【问题描述】:
早些时候,我设法从我的 index.html 的外部 html 文件中加载 html 代码
<head>
<link rel="import" href="html/html_snippets.html">
</head>
然后用
找到它var mySnippet = $(".foo").html();
但现在我开始收到有关 CORS 政策的错误:
Access to Imported resource at 'file:///path/html/html_snippets.html' from origin 'file://' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access.
我无法让它工作。
我怎样才能覆盖它,我需要在外部文件中有 html sn-ps 并在启动时加载它们一次,然后再处理它们。
【问题讨论】:
-
这个问题和答案对我没有帮助,我需要在本地拥有文件,并且不想对所有内容都使用外部库...
标签: javascript jquery html cors