In web development we often need to implement a timed refresh of a page:
1. To keep the value of the session or to check whether the session value is empty (for example, to prevent the same user from repeatedly logging in);
2. Realize the real-time message in the station;
3. Regularly update page data and so on. But we search on the Internet will find a lot of time to refresh the page, the simplest way is to add the following code between
Add code between
<meta http-equiv= "Refresh" content= "5" url= "example.aspx"/>
Description: The value of the content represents the interval between page refreshes, in seconds
The value of the URL specifies the refreshed page
Another way is to use JavaScript to refresh the page regularly
JavaScript periodically refreshes the page, this code I have not tested
<script>
var limit= ":"
if (document.images) {
var parselimit=limit.split (":");
parselimit=parselimit[]*+parselimit[]*;
}
function Beginrefresh () {
if (!document.images) return
;
if (parselimit==)
window.location.reload ();
else{
parselimit-=;
Curmin=math.floor (parselimit/);
cursec=parselimit%;
if (curmin!=)
curtime=curmin+ "min" +cursec+ "SEC";
else
curtime=cursec+ "SEC";
Window.status=curtime;
SetTimeout ("Beginrefresh ()",);
}
}
Window.onload=beginrefresh;
</script>
Add to the center of the body, here is 0:10 for 10 seconds, you can customize
The above is a small set to introduce Ajax to achieve flicker-free time page instance code, hope to help everyone, if you want to learn more information please pay attention to cloud Habitat community website!