JQuery Reload Page After 5 Seconds Example
If you require to make auto refresh your web page after some time period using jquery or code javascript then you can do it you can do it using javascript. we will auto reload page using setTimeout(), setInterval() and meta http-equiv tag. we can simple do it in php, .net, java, laravel, codeigniter etc.
Sometimes, we require to reload page after every 5 seconds, 10 seconds, 15 seconds, 20 seconds, 25 seconds, 30 seconds etc. In this post i will explain how to do it and there are many way to refresh html page. So here you will see three example of auto refresh php page using javascript, you can also manually interval time of page refresh. So let's see bellow examples:
There are listed examples bellow:
1)Example 1(Using setTimeout)
2)Example 2(Using setInterval)
3)Example 3(Using meta)
Example 1(Using setTimeout)
<!DOCTYPE html>
<html>
<head>
<title>Page Reload after 10 seconds</title>
</head>
<body>
<h2>Hi, I am Itsolutionstuff.com</h2>
</body>
<script type="text/javascript">
setTimeout(function(){
location.reload();
},10000);
</script>
</html>
Example 2(Using setInterval)
<!DOCTYPE html>
<html>
<head>
<title>Page Reload after 10 seconds</title>
</head>
<body>
<h2>Hi, I am Itsolutionstuff.com</h2>
</body>
<script type="text/javascript">
function autoRefreshPage()
{
window.location = window.location.href;
}
setInterval('autoRefreshPage()', 10000);
</script>
</html>
Example 3(Using meta)
<!DOCTYPE html>
<html>
<head>
<title>Page Reload after 10 seconds</title>
<meta http-equiv="refresh" content="10" />
</head>
<body>
<h2>Hi, I am Itsolutionstuff.com</h2>
</body>
</html>
Above three example, will auto refresh after every 10 seconds, you can also modify it. because it's very simple.
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
- JQuery Moment Add Days to Date Example
- How to Remove Element from Array in JQuery?
- JQuery Get Days Difference Between Two Dates Example
- How to Remove Key Value from Array using JQuery?
- How to Get Selected Radio Button Value in JQuery?
- JQuery Rotate Image Animation Example Code
- How to Stop Setinterval() After Sometimes in JQuery?
- JQuery Datepicker Example using JQuery UI JS
- How to Create Scroll to Top of the Page by JQuery Animate?
- How to Redirect Another Web Page in JQuery?
- Check and Uncheck All Checkbox using JQuery Example
- How to Allow Only One Checkbox Checked at a Time in JQuery?
- How to Convert Line Breaks to br in jQuery ?
- How to Check Object is Empty or Not in JQuery?