Html 如何通过 https 修复 css 和 js 的“阻止加载混合活动内容”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32307235/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 18:08:38  来源:igfitidea点击:

How to fix "Blocked loading mixed active content" for css and js over https

htmlcsshttphttpsmixed-content

提问by JROB

When attempting to view my site over https, I keep getting a "Blocked loading mixed active content" error in my Firefox console. I am getting this error only for my css and js file.

尝试通过 https 查看我的网站时,我的 Firefox 控制台中不断出现“阻止加载混合活动内容”错误。我只为我的 css 和 js 文件收到此错误。

The reason I am so confused is because the reference to the files in the page code itself is https:

之所以这么困惑,是因为页面代码本身对文件的引用是https:

<link rel="stylesheet" href="https://www.example.com/style.css">

But in the console, it shows it as http:

但是在控制台中,它显示为 http:

Blocked loading mixed active content "http://www.example.com/style.css"[Learn More]

阻止加载混合活动内容“ http://www.example.com/style.css”[了解更多]

I can do a view source on the page and search for "http://" and there are no results anywhere on the page.

我可以在页面上查看源代码并搜索“http://”,页面上的任何地方都没有结果。

Any ideas?

有任何想法吗?

回答by Marcos Pérez Gude

I think that you can try with relative protocol caller.

我认为您可以尝试使用相关协议调用者。

<link rel="stylesheet" href="//www.example.com/style.css">
                    ---------^^

if your users visit your web in http, it loads http, and if the user visit under https it loads https.

如果您的用户以 http 访问您的网站,则加载 http,如果用户以 https 访问,则加载 https。