如何修复 "load unsafe scripts"?

How to fix "load unsafe scripts"?

所以我将从头开始。

基本上我从 themeforest 购买了一个模板,然后在标记编辑器中手动编辑代码以符合我的喜好。

完成后,我决定在 github 页上托管我的网站 - 我像您一样将我的代码目录上传到存储库。

这是我存储库的 link: https://github.com/KristofferHari/kristofferhari.github.io

这是我当前网站 URL 的 link: https://kristofferhari.github.io/(如您所见,一切都有点问题)


所以我设法联系了卖家,这是我得到的:

The reason for that is because the resources are using a http connection and they can’t be loaded on https connection website. So you have to upload all the resources (scripts/stylesheets) to github in order to use them on github.

所以我想通过我的浏览器,我试图通过 https 连接而不是 http 连接到我的网站。 (这是真正导致问题的原因吗,http 连接和 https 之间有什么区别?)

其次,我如何将我所有的资源(scripts/stylesheets)上传到github?

提前致谢!

有一个相对简单的解决方案:使用 protocol-relative URL 格式。

例如你的错误

Mixed Content: The page at 'https://kristofferhari.github.io/' was loaded over HTTPS, but requested an insecure stylesheet 'http://fonts.googleapis.com/css?family=Open+Sans:400,700,300,900'. This request has been blocked; the content must be served over HTTPS.

问题是你正在加载

http://fonts.googleapis.com/css?family=Open+Sans:400,700,300,900'

来自

https://kristofferhari.github.io/

该页面是安全的 (HTTPS),但它正在加载不安全的内容 (HTTP)。

要修复它,您基本上需要将样式表更改为:

https://fonts.googleapis.com/css?family=Open+Sans:400,700,300,900'

但更灵活的解决方案是使用协议相关格式:

//fonts.googleapis.com/css?family=Open+Sans:400,700,300,900'

然后将在 http 或 https 上运行。

将此更改应用于所有包含的资源。