简体   繁体   中英

HTML5/Javascript not executing in firefox - XML reading

I'm trying to get some code working that reads information in from an xml file. This works fine in google chrome but when I try to get it to work with firefox it refuses to load the html5 video I have linked. I've read in places that firefox has a different way of bringing in xml as it treats local content as insecure. Is this correct?

A working example can be found at www.oupnmv.com/dev/

My code:

            <!DOCTYPE HTML>
            <html>
            <head>
            <meta charset="UTF-8">
            <title>Testing HTML5 pausing</title>

            </head>

            <body>
            <video id="myvid" width="320" height="240" controls>
              <source src="video.m4v" type="video/mp4" />
              Your browser does not support the video tag.
            </video>
            <div id="time"></div>
            <script type="text/javascript">
            (function(){
                    var v = document.getElementsByTagName('video')[0]
                    var t = document.getElementById('time');
                var i = new Array("5", "10", "15", "25");
                var toggle = 0;
                var time;
                var c = 0;
                var cue = new Array();


                function callXML(cue){
                var b = 0;
                xmlhttp=new XMLHttpRequest();
                xmlhttp.open("GET", "cue_word.xml", false);
                xmlhttp.send();
                xmlDoc=xmlhttp.responseXML;
                x = xmlDoc.getElementsByTagName("Cue");
                for (b=0;b<x.length;b++){

                cue[b] = xmlDoc.getElementsByTagName("Cue")[b].getAttribute("value");
                }
                }

                callXML(cue);
                v.addEventListener('timeupdate',function(event){
                 //t.innerHTML = v.currentTime;
                  time = parseInt(v.currentTime);
                      if (time == i[c] && toggle == 0){
                    v.pause();
                    t.innerHTML = "Enter some test questions here ";
                    t.innerHTML += cue[c];
                    //toggle = 1;
                    c++;
                    }
              },false);
             })();

            </script>
            </body>
            </html>

You're using an H.264 video. Firefox does not support those, and Chrome is planning to remove support for them as well. Opera doesn't support them either.

您是否检查了Firefox的错误控制台,看是否有什么不应该的样子?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM