2015-01-08 61 views
0

我正在嘗試向我的網站添加視頻,以便在視頻完成時將其重定向到我網站上的另一個頁面。我已經看過幾個論壇,但是他們沒有一個在我的情況下做我需要的東西。這裏是我試圖重定向的視頻的嵌入代碼...視頻完成後重定向iframe視頻?

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

在此先感謝!

+0

請張貼代碼的其餘部分,以及 – Breakpoint

回答

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 
0

掌有一個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();