Sank Finatra
Sank Finatra

Reputation: 354

How to run HTTP sourced javascript on HTTPS site?

I'm trying to run the ConvNetJS example through the Cloud9 online IDE. The script included works when it is inside the HTML, but not when I link it as follows:

<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>

with the javascript inside script.js:

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);
});

When I run the application through the IDE I get this warning through the console: 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.

How do I get around this? I am using chrome and letting it run 'insecure scripts'. Thanks for giving this a read, here's a puppy

Upvotes: 0

Views: 680

Answers (2)

Louys Patrice Bessette
Louys Patrice Bessette

Reputation: 33933

You just can't load unsecured content without having this warning.

The only thing you can do when you have some unsecured external content to load is to copy that content and save it on your secured domain.
This way, you are able to run it from a secured address (yours).

NOW, cs.stanford.edu is a secured website.
So just add the https: in front of //cs.stanford.edu/people/karpathy/convnetjs/build/convnet-min.js and there will be no warning.

Upvotes: 1

fung
fung

Reputation: 639

How about try to add https: in front of your cdn //cs.stanford.edu/people/karpathy/convnetjs/build/convnet-min.js.

Perheps something like https://cs.stanford.edu/people/karpathy/convnetjs/build/convnet-min.js should prevent Chrome warning?

Upvotes: 0

Related Questions