This question already has an answer here:
这个问题已经有了答案:
- URI starting with two slashes … how do they behave? 4 answers
- URI以两个斜线开始…它们的行为如何?4答案
More and more, began to notice that the links in the source code on Web sites begin with two slashes. For example:
越来越多的人开始注意到网站源代码中的链接以两个斜线开头。例如:
<a href="//example.com/1.png">Image</a>
Why do it?
为什么这样做?
1 个解决方案
#1
35
It's a protocol-relative URL (typically HTTP or HTTPS). So if I'm on http://example.org
and I link (or include an image, script, etc.) to //example.com/1.png
, it goes to http://example.com/1.png
. If I'm on https://example.org
, it goes to https://example.com/1.png
.
它是一个协议相关的URL(通常是HTTP或HTTPS)。所以,如果我在http://example.org上链接(或包含图像、脚本等)到// / example.com/1.pngng,它会链接到http://example.com/1.png。如果我在https://example.org上,它会转到https://example.com/1.png。
This lets you easily avoid mixed content security errors.
这使您可以轻松地避免混合内容安全错误。
#1
35
It's a protocol-relative URL (typically HTTP or HTTPS). So if I'm on http://example.org
and I link (or include an image, script, etc.) to //example.com/1.png
, it goes to http://example.com/1.png
. If I'm on https://example.org
, it goes to https://example.com/1.png
.
它是一个协议相关的URL(通常是HTTP或HTTPS)。所以,如果我在http://example.org上链接(或包含图像、脚本等)到// / example.com/1.pngng,它会链接到http://example.com/1.png。如果我在https://example.org上,它会转到https://example.com/1.png。
This lets you easily avoid mixed content security errors.
这使您可以轻松地避免混合内容安全错误。