'Switch iframe source' works locally but not on Github Pages site












0















I'm trying to use a function that switches an iframe's source link on Github Pages. It is from here.



The iframe sources are p5.js sketches also hosted on Github Pages. The whole page (121templatetwo) works locally but when pushed to Github Pages, the iframe is empty.



Link to 121templatetwo repo: https://github.com/lilykdonaldson/121templatetwo



Code for iframe switcher (which is also in the repo):



var switcher$ = $('.switcher'),          // select element
switchTarget$ = $('.switch-target'); // iframe

switcher$.on('change', switchIframeSrc); // event binding

// our functiono to switch the iframe src
function switchIframeSrc() {
// set the 'src' attribute of the iframe
// to the value of the selected option
switchTarget$.attr('src', switcher$.val());
}

// call the method on load
switchIframeSrc();


And the link to the Github Page where the iframe is empty.










share|improve this question





























    0















    I'm trying to use a function that switches an iframe's source link on Github Pages. It is from here.



    The iframe sources are p5.js sketches also hosted on Github Pages. The whole page (121templatetwo) works locally but when pushed to Github Pages, the iframe is empty.



    Link to 121templatetwo repo: https://github.com/lilykdonaldson/121templatetwo



    Code for iframe switcher (which is also in the repo):



    var switcher$ = $('.switcher'),          // select element
    switchTarget$ = $('.switch-target'); // iframe

    switcher$.on('change', switchIframeSrc); // event binding

    // our functiono to switch the iframe src
    function switchIframeSrc() {
    // set the 'src' attribute of the iframe
    // to the value of the selected option
    switchTarget$.attr('src', switcher$.val());
    }

    // call the method on load
    switchIframeSrc();


    And the link to the Github Page where the iframe is empty.










    share|improve this question



























      0












      0








      0








      I'm trying to use a function that switches an iframe's source link on Github Pages. It is from here.



      The iframe sources are p5.js sketches also hosted on Github Pages. The whole page (121templatetwo) works locally but when pushed to Github Pages, the iframe is empty.



      Link to 121templatetwo repo: https://github.com/lilykdonaldson/121templatetwo



      Code for iframe switcher (which is also in the repo):



      var switcher$ = $('.switcher'),          // select element
      switchTarget$ = $('.switch-target'); // iframe

      switcher$.on('change', switchIframeSrc); // event binding

      // our functiono to switch the iframe src
      function switchIframeSrc() {
      // set the 'src' attribute of the iframe
      // to the value of the selected option
      switchTarget$.attr('src', switcher$.val());
      }

      // call the method on load
      switchIframeSrc();


      And the link to the Github Page where the iframe is empty.










      share|improve this question
















      I'm trying to use a function that switches an iframe's source link on Github Pages. It is from here.



      The iframe sources are p5.js sketches also hosted on Github Pages. The whole page (121templatetwo) works locally but when pushed to Github Pages, the iframe is empty.



      Link to 121templatetwo repo: https://github.com/lilykdonaldson/121templatetwo



      Code for iframe switcher (which is also in the repo):



      var switcher$ = $('.switcher'),          // select element
      switchTarget$ = $('.switch-target'); // iframe

      switcher$.on('change', switchIframeSrc); // event binding

      // our functiono to switch the iframe src
      function switchIframeSrc() {
      // set the 'src' attribute of the iframe
      // to the value of the selected option
      switchTarget$.attr('src', switcher$.val());
      }

      // call the method on load
      switchIframeSrc();


      And the link to the Github Page where the iframe is empty.







      javascript html iframe github-pages p5.js






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 1:20









      Kevin Workman

      34.3k54173




      34.3k54173










      asked Nov 25 '18 at 22:44









      Lily DonaldsonLily Donaldson

      32




      32
























          1 Answer
          1






          active

          oldest

          votes


















          0














          When you encounter issues like this, your first step should always be to check your developer tools, especially the JavaScript console and the network tabs.



          This is where any errors you're getting will show up. In your case, you're getting two errors:



          Mixed Content: The page at 'https://lilykdonaldson.github.io/121templatetwo/' was loaded over HTTPS, but requested an insecure script 'http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'. This request has been blocked; the content must be served over HTTPS.

          index.js:1 Uncaught ReferenceError: $ is not defined
          at index.js:1


          So, your page is loaded over HTTPS, which means it can't load script files over HTTP. This is preventing you from loading JQuery, which is breaking everything else. This works locally because presumably you're loading via a file:// URL.



          The quick fix to this is to switch your JQuery URL to HTTPS instead.



          But in the future, check out the developer tools.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53472760%2fswitch-iframe-source-works-locally-but-not-on-github-pages-site%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            When you encounter issues like this, your first step should always be to check your developer tools, especially the JavaScript console and the network tabs.



            This is where any errors you're getting will show up. In your case, you're getting two errors:



            Mixed Content: The page at 'https://lilykdonaldson.github.io/121templatetwo/' was loaded over HTTPS, but requested an insecure script 'http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'. This request has been blocked; the content must be served over HTTPS.

            index.js:1 Uncaught ReferenceError: $ is not defined
            at index.js:1


            So, your page is loaded over HTTPS, which means it can't load script files over HTTP. This is preventing you from loading JQuery, which is breaking everything else. This works locally because presumably you're loading via a file:// URL.



            The quick fix to this is to switch your JQuery URL to HTTPS instead.



            But in the future, check out the developer tools.






            share|improve this answer




























              0














              When you encounter issues like this, your first step should always be to check your developer tools, especially the JavaScript console and the network tabs.



              This is where any errors you're getting will show up. In your case, you're getting two errors:



              Mixed Content: The page at 'https://lilykdonaldson.github.io/121templatetwo/' was loaded over HTTPS, but requested an insecure script 'http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'. This request has been blocked; the content must be served over HTTPS.

              index.js:1 Uncaught ReferenceError: $ is not defined
              at index.js:1


              So, your page is loaded over HTTPS, which means it can't load script files over HTTP. This is preventing you from loading JQuery, which is breaking everything else. This works locally because presumably you're loading via a file:// URL.



              The quick fix to this is to switch your JQuery URL to HTTPS instead.



              But in the future, check out the developer tools.






              share|improve this answer


























                0












                0








                0







                When you encounter issues like this, your first step should always be to check your developer tools, especially the JavaScript console and the network tabs.



                This is where any errors you're getting will show up. In your case, you're getting two errors:



                Mixed Content: The page at 'https://lilykdonaldson.github.io/121templatetwo/' was loaded over HTTPS, but requested an insecure script 'http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'. This request has been blocked; the content must be served over HTTPS.

                index.js:1 Uncaught ReferenceError: $ is not defined
                at index.js:1


                So, your page is loaded over HTTPS, which means it can't load script files over HTTP. This is preventing you from loading JQuery, which is breaking everything else. This works locally because presumably you're loading via a file:// URL.



                The quick fix to this is to switch your JQuery URL to HTTPS instead.



                But in the future, check out the developer tools.






                share|improve this answer













                When you encounter issues like this, your first step should always be to check your developer tools, especially the JavaScript console and the network tabs.



                This is where any errors you're getting will show up. In your case, you're getting two errors:



                Mixed Content: The page at 'https://lilykdonaldson.github.io/121templatetwo/' was loaded over HTTPS, but requested an insecure script 'http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'. This request has been blocked; the content must be served over HTTPS.

                index.js:1 Uncaught ReferenceError: $ is not defined
                at index.js:1


                So, your page is loaded over HTTPS, which means it can't load script files over HTTP. This is preventing you from loading JQuery, which is breaking everything else. This works locally because presumably you're loading via a file:// URL.



                The quick fix to this is to switch your JQuery URL to HTTPS instead.



                But in the future, check out the developer tools.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 26 '18 at 1:19









                Kevin WorkmanKevin Workman

                34.3k54173




                34.3k54173
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53472760%2fswitch-iframe-source-works-locally-but-not-on-github-pages-site%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Wiesbaden

                    Marschland

                    Dieringhausen