Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What protocol is loaded when using protocol-relative URLs? [closed]

Tags:

url

protocols

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?

like image 363
Mackelito Avatar asked Aug 22 '12 08:08

Mackelito


1 Answers

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:

  • Is it valid to replace http:// with // in a <script src="http://...">?
  • Can I change all my http:// links to just //?
like image 195
BoltClock Avatar answered Oct 08 '22 19:10

BoltClock