Javascript to stop HTML5 video playback on modal window close(Javascript 在模态窗口关闭时停止 HTML5 视频播放)
问题描述
我在模态窗口上有一个 html5 视频元素.当我关闭窗口时,视频继续播放.我是 JS 的新手.有没有一种简单的方法可以将视频播放停止功能绑定到窗口关闭按钮?下面是我的html页面:
I've got a html5 video element on a modal window. When I close the window the video continues to play. I'm a total newbie to JS. Is there an easy way to tie a video playback stop function to the window close button? Below is my html page:
非常感谢任何输入.
谢谢.
推荐答案
我正在使用以下技巧来停止 HTML5 视频.pause() 关闭模态视频并设置 currentTime = 0;
I'm using the following trick to stop HTML5 video. pause() the video on modal close and set currentTime = 0;
现在您可以使用 stopVideo() 方法停止 HTML5 视频.喜欢,
Now you can use stopVideo() method to stop HTML5 video. Like,
这篇关于Javascript 在模态窗口关闭时停止 HTML5 视频播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!