using // instead of protocol:// [duplicate]

邮差的信 提交于 2019-11-30 18:42:16

It's called a "protocol-relative URL". Similar to how a url starting with "/" is relative to the root of the current domain, a URL starting with "//" will link to the specified host and path, but using whatever protocol the current page was loaded using.

There's a nice description of them, and why they're useful, on the Wikimedia blog:

http://blog.wikimedia.org/2011/07/19/protocol-relative-urls-enabled-on-test-wikipedia-org/

Basically it gives you the ability to spit out one URL and have it use whatever protocol is currently being used.

Facebook probably uses the same HTML code regardless of whether the user is on HTTP or HTTPS. It's a way to fully qualify the domain without specifying the protocol.

It's another type of relative URL, it uses the same protocol that the page is on.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!