JQuery Redirect to Another Page After 5 Seconds Example
If you are looking for how to redirect to another page in jquery after 5 seconds then i will give you simple example to redirect to url after 10 seconds, 15 seconds, 30 seconds or any specific time in jquery. we will use setTimeout() for redirect to url after 5 seconds in jquery.
In this example we will create one button to redirect another page after 2 seconds. when you click on that button, then button will say you "Redirecting soon....". After 5 seconds it will redirect to given url page.
You can see bellow full example that will help to redirecting to another page url in jquery.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Jquery Redirect to Another Page After 5 Seconds Example - ItSolutionStuff.com</title>
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
</head>
<body>
<button>Click to redirect</button>
<script type="text/javascript">
$("button").click(function(){
$(this).text('Redirecting soon....');
var delay = 2000;
var url = 'https://itsolutionstuff.com'
setTimeout(function(){ window.location = url; }, delay);
})
</script>
</body>
</html>
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Get Selected Radio Button Value in JQuery?
- How to Remove Empty or Null Values from JSON using JQuery?
- Add Edit Delete Table Row Example using JQuery
- How to Remove Empty or Null Values from Array in JQuery?
- JQuery - How to Push Specific Key and Value in Array?
- How to Remove All Spaces from String in JQuery?
- JQuery Reload Page After 5 Seconds Example
- JQuery Email Autocomplete using Email-autocomplete JS
- JQuery Hide and Show Password using Eye Icon Example
- JQuery Chosen Multi Select Dropdown Example
- How to Get Max Attribute Value in JQuery?
- Check and Uncheck All Checkbox using JQuery Example
- How to Allow Only One Checkbox Checked at a Time in JQuery?
- How to Check Object is Empty or Not in JQuery?