Want to redirect video viewers to a new page or website when a video finishes playing? This short HTML and JavaScript code example demonstrates how to do it with an mp4 video on a web page.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"> </script> <script type="text/javascript"> $(document).ready(function(){ $("#myVideo").bind('ended', function(){ location.href="https://www.google.com"; }); }); </script> <video id="myVideo" width="320" height="240" controls="controls"> <source src="travis_scott_drake.mp4" type="video/mp4" /> <source src="travis_scott_drake.ogg" type="video/ogg" /> Your browser does not support the video tag. </video> |