【问题标题】:What are the advantages of leaving out out the protocol for src=? [duplicate]省略 src= 的协议有什么好处? [复制]
【发布时间】:2019-02-20 06:18:58
【问题描述】:

我看到 jQuery 的 src URL 没有指定协议:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<script>

这是标准吗? 省略协议的优缺点是什么?

【问题讨论】:

    标签: html url protocol-relative


    【解决方案1】:

    这是一个简写。它将使用当前源使用的任何协议,而无需明确声明并避免可能的混合内容警告。

    参见RFC,第 3 和 4.2 节

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-11
      • 2011-11-05
      • 1970-01-01
      • 2011-07-22
      • 2016-07-28
      • 2011-11-04
      • 2018-10-03
      相关资源
      最近更新 更多