0

I'm trying to make it so when someone visits my homepage they will see a short video, then be redirected to another webpage. My goal is to have it redirect the user to the second page after the video ends, no matter how long the length of the video is. Eg. 4 seconds, or 5 min, etc. I know my code here is different from what I want to get to, but I'm sure I am close to the answer.

This is what I have so far:

<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<meta http-equiv="refresh" content="1.10;URL='https://example.com/page2'" />
</head>
<body>
<video autoplay="" id="video">
<source src="hi.mp4" type="video/mp4"/>
</video>
</body>
</html>

I've seen it done before on other sites where after the video finishes it would then redirect the user to another page. I've gotten as far as setting a time before it refreshes to another page, but is there some other way where I can make it when the video ends? Any examples would be appreciated.

GBF
  • 29
  • 5
  • You’ll need to use JavaScript for this (what if the user pauses the video, thus changing the time the redirect will happen?) Not sure if the `video` element has a „video completed“ event you can hook into through JavaScript or whether you’ll need to use a custom player that offers the functionality – Pekka Sep 22 '16 at 10:57
  • There indeed seems to be an `ended` event, although support may be patchy https://developer.mozilla.org/en/docs/Web/Guide/Events/Media_events – Pekka Sep 22 '16 at 10:58
  • There are no controls to the video. It's just meant to be a quick little intro before being redirected to another page. Thank you though for the ended event, I'll look into it. – GBF Sep 22 '16 at 11:00
  • Yeah. There is a nice code snippet at the end of the events list that should be easy to modify. There’s also more on SO, check out the duplicate link – Pekka Sep 22 '16 at 11:02

0 Answers0