Pause html5 video when user switches tab
问题 I have an HTML5 video embedded on my webpage: <video id="myvideo"> <source src="videos/myvideo.mp4"> </video> And I have a bit of jQuery to pause the video when the user goes to a different browser window or tab. And also to play the video when the user returns: // pause when the user leaves this window/tab $(window).blur(function(){ $('#myvideo').get(0).pause(); }); // play when the user returns to this window/tab $(window).focus(function(){ $('#myvideo').get(0).play(); }); The problem with