首页 > 遇到一个奇怪的问题

遇到一个奇怪的问题

在移动端给video加了一个play事件,然后给个暂时,
可是在里面我想让他页面跳转,既然没反应,
这是怎么回事??

                var ss = document.getElementById('video');
            
                ss.addEventListener('play',function(e){
                    
                        ss.pause();
                        location.href = 'http://www.baidu.com';    
                    
    
                },false)

解决了用了一个定时器去监测

var ss = document.getElementById('media');
            var flag = false;
            var timer = null;
            ss.addEventListener('play',fnplay)

            function fnplay(){
                flag = true;
                ss.pause();

            }
            timer = setInterval(function(){
                if(flag){
                    window.location.href = 'http://www.baidu.com';
                    clearInterval(timer);
                }
            },1000)

window.location.href
【热门文章】
【热门文章】