Reputation: 5858
I was checking some docs and a customer asked me to change some links at the best way... right now they are only as //domain.com
and i want to know whats the difference between use http://domain.com
than only //domain.com , could also be /domain.com
?
would be a problem if i use only //
for some old browsers or if use only one /
?
Currently I am trying with //domain.com only, but I havent checked if older browsers work correctly with this.
Any idea? Thanks
Upvotes: 1
Views: 647
Reputation: 32693
//domain.com
doesn't include a protocol. So if you were linking to a script (or other resource) on another host, this is a nice way to provide the URL without having to manually change it between HTTP and HTTPS, the browser will use the current protocol that the page was accessed on. This is commonly used when linking to scripts or other resources hosted on a CDN.
In some browsers, if you try to use an HTTP hosted script when you've accessed the site via HTTPS, you'll get a message saying something about "Only secure content is displayed. [Show all content] [Close]" or something to that effect. It often confuses users, and using the protocol relative version of the URL helps avoid that issue.
Upvotes: 3
Reputation: 5271
First of all, /domain.com
would actually be a domain-relative link leading to http://domain.com/domain.com
, so that's right out.
//domain.com/
is a _protocol-relative URL, meaning, that if this URL is found on HTTP pages, the final URL will be http://domain.com
, while, if the URL is found on HTTPS pages, the resulting URL will be https://domain.com
.
http://domain.com/
is an absolute URL and will stay this way forever.
Upvotes: 1