Home > OS >  How can I display a contact form after a video ends on my website using javascript?
How can I display a contact form after a video ends on my website using javascript?

Time:06-29

<script type='text/javascript'> document.getElementsByClassName('hideVideo').addEventListener('ended',myHandler,false); function myHandler(e) { var hideVideo = document.getElementsByClassName("hideVideo")[0]; hideVideo.style.display = "none"; } </script>

I'm creating a website where only 1 video is shown on the entire page. What I want is after the video ends, contact form should come as a pop up and the video should disappear. How can I do this using javascript?

CodePudding user response:

I think this will with what you want to do:

<video id="sample-video" style="max-width:100%;width:100%;" controls="">
    <source src="" type="video/mp4">
</video>
var v = document.getElementById('sample-video');
v.play();
v.addEventListener('ended', function () { 
  // trigger the form to show 
},false);

This is the source

CodePudding user response:

You can find there what you need about html video element events and more.

HTML Audio/Video Properties

  • Related