Displaying new webpage after HTML5 video is done
Question
I have a page which autoplays a video. How would I redirect and/or display a webpage when the video is done being watched? Thanks.
La solution
Use the ended
event:
var videoElement = document.querySelector('video'); // or whatever
videoElement.addEventListener('ended', function (){
window.location = 'http://newpage.com';
});
See it here in action: http://jsfiddle.net/bCBhD/
Autres conseils
"onended" is a standard event for html objects which you can use. Documentation here: http://www.w3schools.com/tags/ref_eventattributes.asp
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow