Live data from Hacker News

"//" should indicate a URL

skyb.us

11–20 of 28 posts

Re: "//" should indicate a URL

#13
post #2

The // prefix is actually used for protocol-relative URLs. So //google.com leads to https://google.com on a page with SSL, and it leads to http://google.com on an unencrypted page. See: http://nedbatchelder.com/blog/200710.html#e20071017T215538 http://paulirish.com/2010/the-protocol-relative-url/

The problem with this is that browsers that are older than IE8 don't support it, so if you're still targeting those users you're SOL on this method.

Re: "//" should indicate a URL

#14
post #2

The // prefix is actually used for protocol-relative URLs. So //google.com leads to https://google.com on a page with SSL, and it leads to http://google.com on an unencrypted page. See: http://nedbatchelder.com/blog/200710.html#e20071017T215538 http://paulirish.com/2010/the-protocol-relative-url/

The problem with this is that browsers that are older than IE8 don't support it, so if you're still targeting those users you're SOL on this method.

I've used this technique since 2006 or so with IE6. The only concern I know of relates to using odd port numbers without a protocol in IE (but I don't think this is a concern if the protocol is relative). At the time, every other browser tested worked as well (not that that was much of a shock).

I don't have a copy of IE6 to test on at the moment, but what makes you think IE8 is required for relative protocols?

Re: "//" should indicate a URL

#15
post #2

The // prefix is actually used for protocol-relative URLs. So //google.com leads to https://google.com on a page with SSL, and it leads to http://google.com on an unencrypted page. See: http://nedbatchelder.com/blog/200710.html#e20071017T215538 http://paulirish.com/2010/the-protocol-relative-url/

Conversely, the protocol bit is relevant whenever your link is not domain- or protocol-relative, or when you can't be sure. And you can't be sure . Here's why: if someone saves your page on their hard drive and you're using protocol-relative URLs, the implied "http" just became "file". (Which in fact may be a nice excuse for some clever hacks.) Test it yourself! Save the following snippet to your computer and see how…

HTML Base tag is your friend. http://www.w3schools.com/TAGS/tag_base.asp

Re: "//" should indicate a URL

#16

Earlier quoted context omitted.

The problem with this is that browsers that are older than IE8 don't support it, so if you're still targeting those users you're SOL on this method.

I've used this technique since 2006 or so with IE6. The only concern I know of relates to using odd port numbers without a protocol in IE (but I don't think this is a concern if the protocol is relative). At the time, every other browser tested worked as well (not that that was much of a shock). I don't have a copy of IE6 to test on at the moment, but what makes you think IE8 is required for relative protocols?

IE6 will also fetch some resources twice if they are protocol-relative URLs

Re: "//" should indicate a URL

#19
post #15

Earlier quoted context omitted.

Conversely, the protocol bit is relevant whenever your link is not domain- or protocol-relative, or when you can't be sure. And you can't be sure . Here's why: if someone saves your page on their hard drive and you're using protocol-relative URLs, the implied "http" just became "file". (Which in fact may be a nice excuse for some clever hacks.) Test it yourself! Save the following snippet to your computer and see how…

HTML Base tag is your friend. http://www.w3schools.com/TAGS/tag_base.asp

W3Schools is not your friend. http://w3fools.com/

Re: "//" should indicate a URL

#20
URL detection is tricky because people omit the “http://” part of URLs. It used to be that you could look for stuff beginning with “www.”, but nobody uses “www.” anymore, so now you basically have to have a list of TLDs and look for anything ending in “.”. Now that everybody will be able to register their own TLD, will URL detection even be feasible for humans any more? I’ve been thinking about how we’re going to solve this problem for a while, because we need some kind of notation to replace “.”. I mean I don’t think people will go back to writing " rel="nofollow">http://coca-cola>, so when I saw the title of this post I immediately knew what the idea was: let’s write //coca-cola to denote “the URL coca-cola”. (Unfortunately, both Google Chrome and Safari interpret “//coca-cola” as “file:///coca-cola”.)

I don’t know why everybody is talking about the technical meaning of //coca-cola, as that’s kind of irrelevant. Us web developers will of course still be typing the full http://coca-cola, as we always have.

Post reply on HN