首页 > 解决方案 > Firefox 没有正确触发 setInterval

问题描述

我正在运行以下脚本,以便在视频完全加载后隐藏预加载器。

它工作得很好——但有时这不会在 Firefox 中触发并保持预加载器无限加载。在 Chrome 和 Safari 中运行良好。

这与setInterval有关吗?

谢谢

function checkforLoad() {
    //Every 500ms, check if the video element has loaded
    var b = setInterval(()=>{
        if(vid.readyState === 4){
            //This block of code is triggered when the video is loaded
            console.log("Video is loaded");
            $('#intro').fadeOut(300);

            //stop checking every half second
            clearInterval(b);

        }
    },300);
}

标签: firefoxvideosetinterval

解决方案


推荐阅读