protocol-relative

Absolute URLs omitting the protocol (scheme) in order to preserve the one of the current page

风流意气都作罢 提交于 2019-11-26 00:53:47
问题 I saw the //somepage.com/resource url format. For example: <img src=\"//remotesite.com/image1.jpg\" /> The point of this is that if the current page (the page defining the img tag) is using http , then the request to the remote site is made via http. If it is https - it\'s https. This eliminates browser warnings of not fully encrypted pages. My question is - is this URL format safe to use for all browsers. And is it a standard? 回答1: is this URL format safe to use for all browsers. I can't say

Can I change all my http:// links to just //?

孤人 提交于 2019-11-25 22:25:33
问题 Dave Ward says, It’s not exactly light reading, but section 4.2 of RFC 3986 provides for fully qualified URLs that omit protocol (the HTTP or HTTPS) altogether. When a URL’s protocol is omitted, the browser uses the underlying document’s protocol instead. Put simply, these “protocol-less” URLs allow a reference like this to work in every browser you’ll try it in: //ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js It looks strange at first, but this “protocol-less” URL is the best way

Is it valid to replace http:// with // in a <script src=“http://…”>?

六月ゝ 毕业季﹏ 提交于 2019-11-25 21:48:43
问题 I have the following element: <script type=\"text/javascript\" src=\"https://cdn.example.com/js_file.js\"></script> In this case the site is HTTPS, but the site may also be just HTTP. (The JS file is on another domain.) I\'m wondering if it\'s valid to do the following for convenience sake: <script type=\"text/javascript\" src=\"//cdn.example.com/js_file.js\"></script> I\'m wondering if it\'s valid to remove the http: or https: ? It seems to work everywhere I have tested, but are there any