0

I apologize if this question is simplistic, beginning web developer here.

I have a page that I am serving securely as https. The page uses the following two libraries:

<script src="http://myjs.us/param.js"></script>
<script src="http://myjs.us/entify.js"></script>

I am getting errors of the following type:

[blocked] The page at ... was loaded over HTTPS, but ran insecure content from 'http://myjs.us/param.js': this content should also be loaded over HTTPS.

So I get why I am getting this error, it is because I am loading the javascript libraries from an unsecure source. My question is where can I get these from a secure source?

Thanks in advance.

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171
bob
  • 227
  • 3
  • 17
  • They seem to be rather small files. Can you not copy and paste them into your scripts directly? – itdoesntwork Oct 05 '14 at 22:55
  • You are getting this error since you are loading your js using the http protocol, `http://myjs.us`. You need to change this to https – Abbath Oct 05 '14 at 22:55
  • 1
    Remove the protocol from the URL. use `src="//myjs.us/param.js"` –  Oct 05 '14 at 22:56
  • possible duplicate of [... this content should also be loaded over HTTPS](http://stackoverflow.com/questions/22196927/this-content-should-also-be-loaded-over-https) – Ashkan Mobayen Khiabani Oct 05 '14 at 22:57

2 Answers2

2

The basic solution is to remove the protocol form the URL when you call the javascript, change

<script src="http://myjs.us/param.js"></script>

to this

<script src="//myjs.us/param.js"></script>

With this you ensure that the javascript will load with the same protocol of the entire page.

Be sure that the server supports https (myjs.us for you), otherwise you will get an error like failed to load resource..., In this case, maybe you want to use a CDN with https support, like cdnjs

rogelio
  • 1,541
  • 15
  • 19
0

You can omit the protocol in your URLs:

<script src="//myjs.us/param.js"></script>
<script src="//myjs.us/entify.js"></script>

The browser will default to the current protocol being used by the page, in this case https. Of course, if myjs.us doesn't support https then that would be another issue entirely, and one you can't really solve from your page.

David
  • 208,112
  • 36
  • 198
  • 279