2017-03-02 135 views
0

我有我想播放的簡短HTML5動畫,然後轉到特定鏈接。點擊,播放HTML5視頻,然後轉到鏈接

我發現了類似於我需要的代碼,我只是不知道如何改變它的HTML5動畫。

$('#menu a').click(function(event) { 
event.preventDefault(); 
var href = this.href; 

$('#whatever').animate({ 
    top: '300px' 
}, 500, 
function() { 
    window.location = href; 
}); 
}); 

由於提前, 布賴恩

回答

0

這給一試:

$('#menu a').click(function(event) { 
    var href = this.href; 

    // This will play the video 
    document.getElementById("videoPlayerID").play(); 

    // This will add an event listener that waits for the video to end. 
    // Once it does, it calls the goToLink function and feeds it the href 
    document.getElementById('videoPlayerID').addEventListener('ended', goToLink(href), false); 

    event.preventDefault(); 
}); 

function goToLink(href) { 
    window.location = href; 
}