没有“http|https"的网址 [英] URL without "http|https"
问题描述
我刚刚从一位同事那里了解到,在链接中省略 URL 的http | https"部分将使该 URL 使用其所在页面使用的任何方案.
例如,如果我的页面是通过 http://www.example.com 访问的,并且我有一个链接(注意'//' 在前面):
<a href="//www.google.com">Google</a>
该链接将转到 http://www.google.com.
但是如果我使用相同的链接访问 https://www.example.com 上的页面,它将转到
我想在网上查找有关这方面的更多信息,但想不出合适的搜索词组.如果我搜索没有 HTTP 的 URL",返回的页面是关于具有以下形式的 url:www.example.com",这不是我要查找的内容.
您会称其为无方案 URL 吗?无协议的 URL?
这是否适用于所有浏览器?我在 FF 和 IE 8 中对其进行了测试,并且在两者中都有效.这是标准的一部分,还是我应该测试更多浏览器?
协议相对 URL
您可能会在某些浏览器中收到不寻常的安全警告.
另请参阅维基百科协议相关网址,了解简要定义.>
另见堆栈溢出问题 为什么要使用相对协议的 URL?.
I just learned from a colleague that omitting the "http | https" part of a URL in a link will make that URL use whatever scheme the page it's on uses.
So for example, if my page is accessed at http://www.example.com and I have a link (notice the '//' at the front):
<a href="//www.google.com">Google</a>
That link will go to http://www.google.com.
But if I access the page at https://www.example.com with the same link, it will go to https://www.google.com
I wanted to look online for more information about this, but I'm having trouble thinking of a good search phrase. If I search for "URLs without HTTP" the pages returned are about urls with this form: "www.example.com", which is not what I'm looking for.
Would you call that a schemeless URL? A protocol-less URL?
Does this work in all browsers? I tested it in FF and IE 8 and it worked in both. Is this part of a standard, or should I test more browsers?
Protocol relative URL
You may receive unusual security warnings in some browsers.
See also, Wikipedia Protocol-relative URLs for a brief definition.
At one time, it was recommended; but going forward, it should be avoided.
See also the Stack Overflow question Why use protocol-relative URLs at all?.
这篇关于没有“http|https"的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!