【问题标题】:Why does the CDN's have 2 // instead of http or https in front of the URL为什么 CDN 的 URL 前面有 2 // 而不是 http 或 https
【发布时间】:2013-05-30 00:20:17
【问题描述】:

我不明白为什么要查看以下网站的 CDN,URL 以双“//”开头。我在 JQuery 和 Bootstrap 上看到过这个。放 http:// 还是 https:// 是由人决定的吗?

http://www.bootstrapcdn.com/

<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">

【问题讨论】:

标签: javascript css twitter-bootstrap web cdn


【解决方案1】:

那是protocol relative URL:

如果浏览器正在通过 HTTPS 查看当前页面,那么它将使用 HTTPS 协议请求该资产,否则它通常*会使用 HTTP 请求它。这可以防止 IE 中出现可怕的“此页面同时包含安全和非安全项目”错误消息,从而将您的所有资产请求保持在同一协议中。

【讨论】:

    【解决方案2】:

    就像省略域:href="/folder/file.html",浏览器只是假定当前域。

    在您的情况下,浏览器将采用当前协议。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-19
      • 2015-01-21
      • 1970-01-01
      • 2019-02-27
      • 2016-06-01
      • 2020-12-28
      • 2018-02-12
      • 1970-01-01
      相关资源
      最近更新 更多