5

I just started to test the idea behind "protocol less Urls".

The problem I´m looking to solve is: on a https page I need to load an external css file from http.

Doing this the "normal" way results in failure... the css file is blocked. (Just testing with chrome for now).

So my question is: Will "protocol less Urls" load the file from http/https/both?

isherwood
  • 58,414
  • 16
  • 114
  • 157
Mackelito
  • 4,213
  • 5
  • 39
  • 78
  • Not sure but you can check [this answer](http://stackoverflow.com/questions/3292697/find-out-what-resources-are-not-going-over-https). – The Alpha Aug 22 '12 at 08:41
  • 1
    This is a valid question – Jarrod Sep 02 '14 at 19:02
  • This seems to show up #1 in Google. See http://stackoverflow.com/questions/4831741/can-i-change-all-my-http-links-to-just for detailed answer – epascarello Dec 30 '14 at 21:11
  • btw, protocol-relative URL is now an anti-pattern : http://www.paulirish.com/2010/the-protocol-relative-url/ – user Jan 19 '16 at 16:34

1 Answers1

13

If you're referring to URLs like www.example.com/style.css, that won't work because the protocol is completely missing; a browser will treat www.example.com as some kind of directory path name.

If you're referring to URLs like //www.example.com/style.css, that is a protocol-relative URL; it uses the same protocol as what the browser is already using to request the referring page. For example, if the browser had requested a page with https://www.example.com, then that URL will be requested over HTTPS and not HTTP.

Browser support for these URLs is generally pretty good; see the following questions:

Community
  • 1
  • 1
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356