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.

The provided HTML and JavaScript code snippet serves to control the behavior of an HTML5 video element with the ID “myVideo.” The code imports the jQuery library from a URL and utilizes JavaScript to add functionality to the video playback. When the webpage loads and the document is ready, a jQuery function is triggered.

This function binds to the “ended” event of the video, which occurs when the video playback reaches its end. Upon reaching the end of the video, the script redirects the user’s browser to the URL “https://www.google.com.”

The HTML code following the script tags defines the video player element with the ID “myVideo,” providing a video source in both MP4 and OGG formats, along with a fallback message for unsupported browsers. This combination of HTML and JavaScript ensures that once the video finishes playing, the user is automatically directed to Google’s homepage.