You're assuming people care about that use case. I think in most cases it's irrelevant.
Oh man. Are you really saying that corner cases are a priori negligible? That seems like a dangerous road to start down when you're discussing basic protocols!
If your use case entails people saving your site to disk then you have may not be able to use // for protocol relative links, but most people don't have to worry about such things.
I'm saying that those who need to worry about such things should and the rest of us should not. Nothing more and nothing less.
HTML Base tag is your friend. http://www.w3schools.com/TAGS/tag_base.asp
Re:"//" should indicate a URL
by sleepyhead on Monday June 27, 2011 @04:40AM
(#2700614)
W3Schools is not your friend. http://w3fools.com/
Re:"//" should indicate a URL
by rufibarbatus on Monday June 27, 2011 @08:19AM
(#2701028)
And here it is in the specification:
http://dev.w3.org/html5/spec/Overview.html#the-base-element
And accordingly, adding `<base href="http://example.com/ >` to that test above seems to work well on modern browsers.
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 your browser resolves the URL: