【发布时间】:2011-11-08 13:40:30
【问题描述】:
越来越多,开始注意到网站源代码中的链接以两个斜线开头。例如:
<a href="//example.com/1.png">Image</a>
为什么要这样做?
【问题讨论】:
标签: html hyperlink protocol-relative
越来越多,开始注意到网站源代码中的链接以两个斜线开头。例如:
<a href="//example.com/1.png">Image</a>
为什么要这样做?
【问题讨论】:
标签: html hyperlink protocol-relative
这是一个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。
这可以让您轻松避免混合内容安全错误。
【讨论】: