Home  >  Article  >  Web Front-end  >  How to make timer refresh page

How to make timer refresh page

醉折花枝作酒筹
醉折花枝作酒筹forward
2021-04-13 11:39:503846browse

This article will introduce to you how to refresh the page with a timer. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to make timer refresh page

Let me summarize the three methods of timer refresh

Method 1: Add the setInterval() function

<script language="JavaScript">
  setInterval(function(){
     window.location.reload();
   },3000);  //每隔三秒刷新一次页面
 
</script>

Method 2: Automatically refresh when adding

in the tag. Content represents the refresh interval in seconds. The following code represents the page interval. Refresh once every three seconds

<meta http-equiv="refresh" content="20">

Method 3: This tag is used for timing jumps. The first parameter of content indicates the interval in seconds, and the second parameter indicates the target URL. But if the If the two parameters are set to #, the page will be refreshed.

<meta http-equiv="refresh" content="3;url=#">

Recommended learning: javascript video tutorial

The above is the detailed content of How to make timer refresh page. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete