Skip to content
Advertisement

Why JavaScript is not working in HTTPS on my site

I have just added HTTPS to my site and apparently the only script I have on my site has stopped working. I don’t think it is a problem of the script, but here it is:

function cambiarPestanna(pestannas, pestanna) {

    pestanna = document.getElementById(pestanna.id);
    listaPestannas = document.getElementById(pestannas.id);

    cpestanna = document.getElementById('c' + pestanna.id);
    listacPestannas = document.getElementById('contenido' + pestannas.id);

    i = 0;
    while (typeof listacPestannas.getElementsByTagName('div')[i] != 'undefined') {
        $(document).ready(function() {
            $(listacPestannas.getElementsByTagName('div')[i]).css('display', 'none');
            $(listaPestannas.getElementsByTagName('li')[i]).css('background', '');
            $(listaPestannas.getElementsByTagName('li')[i]).css('padding-bottom', '');
        });
        i += 1;
    }

    $(document).ready(function() {
        $(cpestanna).css('display', '');
        $(pestanna).css('background', 'white');
        $(pestanna).css('padding-bottom', '2px');
    });

}

What is the solution to this problem?

Advertisement

Answer

Add your jQuery file like this, without mentioning the protocol explicitly:

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Removing the http: part from src means you don’t want to load external files/resources with a fixed protocol that you are mentioning in the src. Rather, you want to load the external resources with the same protocol the demanding resource is residing in.

Advertisement