简体   繁体   English

Github页面不能完全正常工作

[英]Github page not working completely

I've created my github.io page but it's graphics are not loading completely and browser display a warning: opera has blocked content of this page which comes from insecure sources. 我已经创建了我的github.io页面,但它的图形没有完全加载,浏览器显示警告:opera已阻止此页面的内容来自不安全的来源。

How to fix this? 如何解决这个问题?

my github page: https://msdeep14.github.io 我的github页面: https//msdeep14.github.io

repo link: https://github.com/msdeep14/msdeep14.github.io repo link: https//github.com/msdeep14/msdeep14.github.io

Page URLs in https should NOT link to http resources. https中的网页网址不应链接到http资源。

You might have hard-coded 'http' only values for your assets like css and images. 您可能只为您的资产(如css和图像)设置了硬编码的“http”值。 Debug your page in inspector and see network log. 在检查器中调试页面并查看网络日志。

Press F12. 按F12。

What Bimal already was trying to say: Your page is served via HTTPS (that is, over an encrypted connection). Bimal已经试图说的是:您的页面是通过HTTPS(即通过加密连接)提供的。 To ensure that everything is secure in such a case, browsers require all resources, like CSS and JavaScript files and images to be also served via HTTPS. 为了确保在这种情况下一切都安全,浏览器需要通过HTTPS提供所有资源,如CSS和JavaScript文件和图像。

The easiest solution in your case is to replace all occurrences of http: with https: and check if the page still works. 在您的情况下,最简单的解决方案是用https:替换所有出现的http: https:并检查页面是否仍然有效。 If it doesn't, then some file is presumably not available via HTTPS. 如果没有,那么某些文件可能无法通过HTTPS获得。 In that case, you might need to add it to your Github repo and change the link accordingly. 在这种情况下,您可能需要将其添加到Github仓库并相应地更改链接。

You can use https:// in the URLs of the external elements used by your page (images, scripts, stylesheets) as other answers suggest. 您可以在页面使用的外部元素的URL(图像,脚本,样式表)中使用https:// ,如其他答案所示。

But you can do even better by using protocol-relative URLs, like this: 但是你可以通过使用协议相对URL做得更好,如下所示:

<link rel="stylesheet" type="text/css" href="//msdeep14.github.io/static/css/syntax.css" />

For URLs of resources located on your own domain you can even use host-relative URLs: 对于位于您自己域中的资源的URL,您甚至可以使用与主机相关的URL:

<link rel="stylesheet" type="text/css" href="/static/css/syntax.css" />

(but you have to stick to the first form for URLs outside your domain). (但您必须坚持使用域外的网址的第一个表单)。

Both the above solutions work (since forever) with all browsers. 上述两种解决方案都适用于所有浏览器(永远都是如此)。 The browser compute the complete URLs using the URL of the current page as base. 浏览器使用当前页面的URL作为基础来计算完整的URL。 This way, when the page is loaded using HTTP , the external resources are also loaded using HTTP and when it is loaded using HTTPS , the resources are also loaded using HTTPS and the browsers do not display annoying warnings. 这样,当使用HTTP加载页面时,外部资源也使用HTTP加载,当使用HTTPS加载时,资源也使用HTTPS加载,浏览器不显示恼人的警告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM