2017-04-16 30 views
0

我试图通过Cloud9在线IDE运行ConvNetJS example。该脚本包括作品时,它是HTML里面,而不是当我将其链接如下:如何在HTTPS网站上运行HTTP源JavaScript?

<html> 
 
<head> 
 
<title>minimal demo</title> 
 
    
 
<!-- CSS goes here --> 
 
<style> 
 
body { 
 
    background-color: #FFF; /* example... */ 
 
} 
 
</style> 
 

 
<!-- http://jquery.com/ --> 
 
<script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script> 
 

 
<!-- http://getbootstrap.com/ --> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 

 
<!-- import convnetjs library --> 
 
<script src="//cs.stanford.edu/people/karpathy/convnetjs/build/convnet-min.js"></script> 
 

 
<!-- app's own JavaScript --> 
 
<!--script type="text/javscript" src="../static/script.js"></script--> 
 

 
</head> 
 
    
 
<body> 
 
<div id="egdiv"></div> 
 
</body> 
 
</html>

里面script.js的JavaScript:

function periodic() { 
 
    var d = document.getElementById('egdiv'); 
 
    d.innerHTML = 'Random number: ' + Math.random(); 
 
}; 
 
    
 
var net; // declared outside -> global variable in window scope 
 
$(function start() { 
 
    // this gets executed on startup 
 
    net = new convnetjs.Net(); 
 
    
 
    // example of running something every 1 second 
 
    setInterval(periodic, 1000); 
 
});

当我通过IDE运行应用程序时,我得到了这个通过控制台警告:Mixed Content: The page at 'https://ide50-stephenwist.cs50.io/' was loaded over HTTPS, but requested an insecure script 'http://cs.stanford.edu/people/karpathy/convnetjs/build/convnet-min.js'. This content should also be served over HTTPS.

我该如何解决这个问题?我使用chrome并让它运行'不安全的脚本'。感谢您给这读,here's a puppy

回答

0

如何尝试添加https:在您的cdn //cs.stanford.edu/people/karpathy/convnetjs/build/convnet-min.js前面。

https://cs.stanford.edu/people/karpathy/convnetjs/build/convnet-min.js这样的问题会导致Chrome预警吗?

1

您不能在没有此警告的情况下加载不安全的内容。

当您加载一些不安全的外部内容时,您唯一能做的就是复制该内容并将其保存在安全域中。
这样,您就可以从安全地址(您的)运行它。

现在,cs.stanford.edu一个安全的网站。
所以只需在//cs.stanford.edu/people/karpathy/convnetjs/build/convnet-min.js前面加上https:即可,并且不会有任何警告。

+0

谢谢你摆脱了这个警告。看起来我的问题是脚本在链接时没有运行是Flask的问题。 –

相关问题