Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么Github页面不允许我的有效HTML?_Javascript_Html_Github_Github Pages_External Script - Fatal编程技术网

Javascript 为什么Github页面不允许我的有效HTML?

Javascript 为什么Github页面不允许我的有效HTML?,javascript,html,github,github-pages,external-script,Javascript,Html,Github,Github Pages,External Script,我目前正在使用W3Schools脚本在Github上为Github页面进行回购。我的index.html代码如下所示: <!DOCTYPE html> <html> <head> <title>[my name] Witness Project</title> <script src="http://w3schools.com/lib/w3data.js"></script>

我目前正在使用W3Schools脚本在Github上为Github页面进行回购。我的index.html代码如下所示:

<!DOCTYPE html>
<html>
    <head>
        <title>[my name] Witness Project</title>
        <script src="http://w3schools.com/lib/w3data.js"></script>
    </head>
    <body>
        <div w3-include-html="common.html"></div>
        <div id="main">
            <h1 style="display:block">This will be my Witness Project soon!</h1>
        </div>
    </body>
    <script>
    w3IncludeHTML();
    </script>
</html>

[我的名字]见证计划
这将是我的见证项目很快!
w3IncludeHTML();
在common.html中,有页眉和页脚的代码:

<link rel="stylesheet" href="common.css">
<div id="header">
    <nav>
        <button type="button"><a href="index.html">Home</a></button>
        <button type="button"><a href="#">Coming Soon</a></button>
        <button type="button"><a href="#">Coming Soon</a></button>
        <button type="button"><a href="#">Coming Soon</a></button>
        <button type="button"><a href="#">Coming Soon</a></button>
    </nav>
</div>

<div id="footer">
    Created as part of <i>The Witness Project</i> at The Key School<br>
    <i>Content of website © 2016 by [my name]</i>
</div>

作为重点学校见证项目的一部分创建
网站内容©2016由[我的姓名]
我正在使用一个脚本描述能够导入其他HTML文件。我不认为CSS是相关的。然而,当我加载Github页面时,我只看到index.html中的元素。但这不是我的错,因为当我从本地文件加载页面时,它看起来就像我期望的那样

图像:
在线:
本地: 发生了什么事?你不能在Github上使用外部JS吗

编辑:我检查了控制台并收到以下消息:

您收到的错误,
已阻止加载混合活动内容”http://w3schools.com/lib/w3data.js“
,表示您有“混合内容”-也就是说,一些内容通过
https
加载,而其他内容通过
http
不安全地加载

通过http加载这样的脚本容易在发送方和接收方之间被篡改,因此这被认为是一种安全风险,(某些)浏览器会阻止它

当您链接到脚本时,您可以在不使用协议的情况下使用
,并且将使用用于加载页面的任何协议(http或https)加载scrpt。这将消除错误

不幸的是,我测试了
https://w3schools.com/lib/w3data.js
它(首先)给了我一个证书错误,然后是404。。。w3schools没有通过https提供该脚本。

在这种情况下,最好是在本地保存一个副本并链接到该副本,而不是CDN。

我猜:CSS没有加载。不知道为什么,但请检查网络选项卡。如果脚本不是从CDN托管的,则可能不允许该脚本。如果页面是https,则脚本也必须是https。如果傻瓜想要一张真正的证书,他们会买一张真的证书cdn@dandavis如果我在脚本标记中将http更改为https,它会工作吗?@OldBunny2800:不,W3傻瓜在那个位置没有可用的证书。你必须重新主持