How can I get a button in HTML5 which when pressed plays a loop video in background and after some time redirects the page to another webpage?
How can I get a button in HTML5 which when pressed plays a loop video in background and after some time redirects the page to another webpage?
2
Answers
If you’re in need of a button you need to use Html to show it on screen and then use JavaScript to play the looping video and after some delay to be redirected. You’ll surely need JavaScript to do these. You should use event listeners and bind the video to be played after clicking and then add setTimeOut to wait for sometime and then use window.location.replace(…) to redirect. Here you can check for better explanation How do I redirect to another webpage?
There is a huge difference between JS and Python:
Python is server-sided and as such run on the server.
JavaScript is client-sided and runs within the browser.
Webservers only work with requests. For obvious security reasons, it can not control or access a browser.
That means a server will never know if a user pressed a button because he has no control to listen to it. You need a client-sided eventListener to check for it. Then you can use a client-side script to send a post request to the server. However, for performance reasons, it should only be done if it is necessary for security reasons or UX (cross-browser and device savings).
What you need to do:
eventListener
to your "button" element (image?) to check forclick
events.setTimeout
function.loop
in your video tag setup.location.href
method within thesetTimeout
to redirect when the time runs out.