简体   繁体   English

查询GitHub页面和JavaScript库不起作用

[英]Query GitHub Pages and JavaScript libs dont't work

I have tried to test a static website with JS libs like JQuery on a GitHub Pages However, it seems that the JS (main site carousel or photo carousel) is not working on GitHub Pages. 我曾尝试在GitHub Pages上使用jQuery之类的JS库测试静态网站,但是JS(主站点轮播或图片轮播)似乎无法在GitHub Pages上运行。

The same code locally and on localhost temporary apache work excelent. 本地和localhost临时apache上的相同代码非常出色。

JQuery as an example: 以JQuery为例:

    <script type="text/javascript">
            if (typeof jQuery == 'undefined') {
                document.write(unescape("%3Cscript src='/javascripts/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
        }
    </script>

What seems to be the problem? 似乎是什么问题?

You are using mixed content. 您正在使用混合内容。 Libraries are not being loaded because their scheme is http , while GitHub Pages is using https : 库未加载,因为它们的方案是http ,而GitHub Pages使用https

Google Chrome控制台错误

You need to change all the resources routes to match https protocols. 您需要更改所有资源路由以匹配https协议。 If the resources websites do not allow you to do that, then you may want to download the libraries and upload to your page, instead of using CDNs. 如果资源网站不允许您这样做,那么您可能希望下载库并上载到页面,而不是使用CDN。 Links will go like this: 链接将如下所示:

<script src='relative/server/folder/to/jquery.min.js' /> 

Also, you may want to read this for further information and instructions. 另外,您可能需要阅读此内容以获得更多信息和说明。


Another points you sould fix: 您需要解决的其他问题:

  • Your website, after loading jQuery, $ is not defined, but jQuery does. 加载jQuery后,您的网站未定义$ ,但jQuery定义了$ You should fix this, or use jQuery instead of $ . 您应该解决此问题,或者使用jQuery代替$
  • After loading your carousssel with jQuery("#mojbanner").load("assets/revslider/moj_slider.html"); 在使用jQuery("#mojbanner").load("assets/revslider/moj_slider.html"); , assets/revslider/moj_slider.html contains more http content (instead of https). assets/revslider/moj_slider.html包含更多http内容(而不是https)。 You should fix this html too. 您也应该修复此html。
  • Try fixing all the errors you see on the Chrome (or Firefox, or whatever explorer) debugging console. 尝试修复在Chrome(或Firefox或其他浏览器)调试控制台上看到的所有错误。

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

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