开发者

Links start with two slashes [duplicate]

开发者 https://www.devze.com 2023-04-02 00:27 出处:网络
This question alrea开发者_如何学Gody has answers here: URI starting with two slashes ... how do they behave?
This question alrea开发者_如何学Gody has answers here: URI starting with two slashes ... how do they behave? (4 answers) Closed 9 years ago.

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?


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.

This lets you easily avoid mixed content security errors.

0

精彩评论

暂无评论...
验证码 换一张
取 消