What protocol is loaded when using protocol-relati

2019-02-14 06:03发布

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?

标签: url protocols
1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-02-14 06:39

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:

查看更多
登录 后发表回答