gpt4 book ai didi

javascript - 跳过 url 中的 http 协议(protocol)不会加载脚本文件

转载 作者:行者123 更新时间:2023-12-03 10:00:41 25 4
gpt4 key购买 nike

我在浏览器中以 file:/// 打开我的index.html,并且没有加载没有协议(protocol)名称的脚本。

<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 链接中的协议(protocol)名称并仍然以 file:/// 格式打开文件吗?

最佳答案

不,您需要编辑index.html 文件并将“http”或“https”添加到脚本标记中。

跳过协议(protocol)意味着使用与页面加载相同的协议(protocol)(例如,如果您同时允许 http 和 https,这很有用)。但在这种情况下,浏览器会将以上解释为:

<script type="text/javascript" language="javascript" src="file:///code.jquery.com/jquery-1.10.2.min.js"></script>

关于javascript - 跳过 url 中的 http 协议(protocol)不会加载脚本文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30613992/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com