Javascript is not working in https

前端 未结 2 1209
清歌不尽
清歌不尽 2020-12-22 13:30

I have just added https to my site and apparently the only script I have in my site has stopped working. I don\'t think it is a problem of the script but here it is:

相关标签:
2条回答
  • 2020-12-22 14:12

    Add your jQuery file like this, without mentioning the protocol explicitely

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

    removing http: part from src means you don't want to load external files/resources with 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.

    0 讨论(0)
  • 2020-12-22 14:25

    Load all the scripts on you page this way:

    <script src="//domain.com/path/script.js"></script>

    The main part is // – it says browser to use current protocol – https in your case.

    For example last version of JQuery from CDN:

    <script src="//code.jquery.com/jquery-2.1.4.min.js"></script>

    0 讨论(0)
提交回复
热议问题