【问题标题】:Links start with two slashes [duplicate]链接以两个斜杠开头[重复]
【发布时间】:2011-11-08 13:40:30
【问题描述】:

越来越多,开始注意到网站源代码中的链接以两个斜线开头。例如:

<a href="//example.com/1.png">Image</a>

为什么要这样做?

【问题讨论】:

    标签: html hyperlink protocol-relative


    【解决方案1】:

    这是一个protocol-relative URL(通常是 HTTP 或 HTTPS)。因此,如果我在http://example.org 上并且我链接(或包含图像、脚本等)到//example.com/1.png,它会转到http://example.com/1.png。如果我在https://example.org,它会转到https://example.com/1.png

    这可以让您轻松避免混合内容安全错误。

    【讨论】:

      猜你喜欢
      • 2016-09-28
      • 2012-01-05
      • 1970-01-01
      • 2011-05-03
      • 2016-05-21
      • 2017-08-12
      • 2014-04-04
      • 2012-05-26
      • 1970-01-01
      相关资源
      最近更新 更多