JavaScript Redirect to a page after few seconds on Button Click


JavaScript Redirect to a page after few seconds on Button Click We can use pure JavaScript function window.location and setTimeoout to redirect to particular page. Let us understand how we can redirect after 1 minutes on button click.


JavaScript Redirect to a page after few seconds on Button Click Example

Here is simple example to redirect after submit button to the specified page-

JavaScript Redirect to a page after few seconds on Button Click Example:

<html>
<head>
<title>JavaScript Redirect</title>
<script>
function toPage() 
{  
window.location="https://www.tutorialsplane.com/ionic-popup"; 
} 
function redirectCustom(){ 
//redirect after 5 seconds for i min pass 60000
setTimeout('toPage()', 5000);
}
</script>
</head>
<body>
<input type="button" name="submit_button" onclick="redirectCustom();" value="Clic Me">

</body>
</html>

Try it »


Advertisements

Add Comment