仅在Firefox中出现奇怪的JavaScript错误

时间:2018-12-06 20:15:57

标签: javascript firefox

Material Components Web页上,我有一个脚本,该脚本创建Audio对象,然后播放它。 您可以通过以下链接找到完整的脚本:https://dev.onlineradioplanet.com/ru/avtoradio/

如果简化代码并仅保留错误代码,那么我们有:

var audio = new Audio();
var radioPage = document.getElementsByClassName('radio')[0];
var player = document.getElementsByClassName('radio__top-player')[0];
//var context = null;
console.log("now=" + (new Date()).getMinutes() + ":" + (new Date()).getSeconds());


function initAudio() {
    console.log("initRadio  ---  " + (new Date()).getMinutes() + ":" + (new Date()).getSeconds());
    addListenersToAudio(audio);
}

if (radioPage) {
    console.log(radioPage + " ---  " + (new Date()).getMinutes() + ":" + (new Date()).getSeconds());
    setTimeout(initAudio, 5000);
}

function addListenersToAudio(audio_item) {

    audio_item.addEventListener("error", function (event) {
        console.log("onerror --- " + (new Date()).getMinutes() + ":" + (new Date()).getSeconds());
    });

}

对于简化的代码,很少复制错误,但复制的是钢。https://onlineradioplanet.com/js/main.min.js?v=1544020229

Firefox从执行audio_item的错误侦听器开始脚本,在初始化之前和调用函数“ addListeners”(或addListenersToAudio相同)之前。

0 个答案:

没有答案