Possible Duplicate:
Is it valid to replace with // in a <script src=“…”>?
We have a site on http[s]://A.example.com/ that references some resources (JS and CSS) on http[s]://A.example.com/
It makes sense, and avoids some browser warnings, if the same scheme is used when referencing the resources as the main site A is using. Site A uses PHP, so we can programmaticly detect the current scheme (http or https) and insert that into the header of the page.
However, we have found that just using '//' instead of the scheme also works.
So site A may reference "//B.example.com/theme/main.css" without a problem in all browsers we have tried, regardless of whether we go to site A using http or https.
My question is: is this a valid URL? It seems to work, but I cannot find anyone else doing it, and I cannot find any examples of this being suggested or recommended.
Yes. It is called a protocol-relative URL. See also Can I change all my http:// links to just //?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With