Refreshing the html page for regular interval time with javascript
One of my friend asked to refresh the HTML page in his project that changes the stock rates every one minutes.i gave him simple solution like
example:1
7 8 9 10 11 12 13 | <script> var timer; function refreshmypage(){ document.location=document.location.href; } timer=setTimeout(refreshmypage,60*1000); </script> |
Add above script after your HTML body content.Here setTimeout function takes two arguments one for function handler and other time to call the function,the time is in milliseconds.so i set to 60* 1000 i.e 60 seconds.
Example :2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <html> <head> <script type="text/javascript"> function load() { setTimeout("refresh()", 2000) } function refresh(){ window.location.reload() load() } </script> </head> <body onload="load()"> </body> </html> |
Above example also can be used.

