javascript - 仅当请求 https 页面时,才通过 https href google 字体

标签 javascript https href

我在网页上使用谷歌字体,但该字体是通过http调用的 -

    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>

如果通过 https 请求页面 - 字体将被识别为不安全内容。

如何请求

<link href='https://fonts.googleapis.com/css

仅当通过 https 连接请求页面时,如果请求 http,则提供 http 服务?

最佳答案

删除http:,这将使URL相对于当前方案

<link href='//fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>

关于javascript - 仅当请求 https 页面时,才通过 https href google 字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19274868/

相关文章:

javascript - 将 html 导出到 Excel : when try to open file it gives prompt like file is corrupted

javascript - 需要帮助创建可保留当前背景和文本颜色的 cookie

java - 如何将 https/ssl 与 Maven/Mortbay Jetty 插件一起使用?

android - HTTPS 不适用于 OkHttp3 和 Retrofit2

ssl - 如何恢复丢失的 IIS Express SSL 证书?

JAVA Selenium - 在循环中从 html 获取 href

javascript - 如何从 javascript 文件复制 href

javascript - 所有外部 js 和 css 文件上的 Gulp 和浏览器同步 404

javascript - 如何使 react 引导表中的列可单击并避免将其显示为 "Add Row"中的文本字段?

javascript - 使用 jQuery 从 href ="tel:"属性中删除无效字符