在 url 中跳过 http 协议不会加载脚本文件
skipping http protocol in url doesn't load the script file
我在浏览器中打开我的 index.html 作为 file:///
并且没有加载没有协议名称的脚本。
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
这在 mozilla 36.0.4 中不起作用,chrome 在我的机器上。
在使用 node-static
服务器时,jquery 文件成功加载。
我们能否跳过 script
链接中的协议名称并仍然以 file:///
打开文件?
您应该编辑(添加 http
)
<script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
因为 // 当它不是 apache 或 iis 时不工作。
不,您需要编辑 index.html 文件并将 'http' 或 'https' 添加到脚本标签。
跳过协议意味着使用与加载页面相同的协议(这在您同时允许 http 和 https 的情况下很有用)。但在这种情况下,浏览器会将上面的内容解释为:
<script type="text/javascript" language="javascript" src="file:///code.jquery.com/jquery-1.10.2.min.js"></script>
我在浏览器中打开我的 index.html 作为 file:///
并且没有加载没有协议名称的脚本。
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.10.2.min.js"></script>
这在 mozilla 36.0.4 中不起作用,chrome 在我的机器上。
在使用 node-static
服务器时,jquery 文件成功加载。
我们能否跳过 script
链接中的协议名称并仍然以 file:///
打开文件?
您应该编辑(添加 http
)
<script type="text/javascript" language="javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
因为 // 当它不是 apache 或 iis 时不工作。
不,您需要编辑 index.html 文件并将 'http' 或 'https' 添加到脚本标签。
跳过协议意味着使用与加载页面相同的协议(这在您同时允许 http 和 https 的情况下很有用)。但在这种情况下,浏览器会将上面的内容解释为:
<script type="text/javascript" language="javascript" src="file:///code.jquery.com/jquery-1.10.2.min.js"></script>