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

How to make timer refresh page

醉折花枝作酒筹
Release: 2021-04-13 11:39:50
forward
3948 people have browsed it

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>
Copy after login

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">
Copy after login

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=#">
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template