视频播放完成后重定向iframe视频?

时间:2015-01-08 04:44:14

标签: javascript html redirect iframe video

我尝试将视频添加到我的网站,以便在视频完成后重定向到我网站上的其他网页。我已经看了几个论坛,但在我的情况下,他们都没有做我需要的论坛。这是我试图重定向的视频的嵌入代码......

<iframe src="//ihigh.volarvideo.com/sheldonclarkcardinals/broadcast/embed/95383?w=640&autoplay=1" frameborder="0" width="640" height="360" scrolling="no"></iframe>

提前致谢!

2 个答案:

答案 0 :(得分:0)

您可以使用jquery setTimeout,但问题是如果视频暂停会出现问题

<iframe src="//www.youtube.com/embed/_OBlgSz8sSM" frameborder="0" width="640" height="360" scrolling="no"></iframe>

setTimeout(function(){
window.location = "http://www.stackoverflow.com";
},56000); // This is equal to the lenght of the video

答案 1 :(得分:0)

Volar有一个javascript API,您可以在其中收听活动。在iframe中添加ID:

<iframe id="my-video" src="//ihigh.volarvideo.com/sheldonclarkcardinals/broadcast/embed/95383?w=640&autoplay=1" frameborder="0" width="640" height="360" scrolling="no"></iframe>

然后在您的网页中加入volarvideo.js并致电:

var i = document.getElementById('my-video');
var v = new Volarvideo();

v.on('onComplete', function() {
   window.location.href = "<desired url>";
}

v.connect(i);
v.play();
相关问题