Let the web page redirect to other pages after opening for a few seconds

Let the web page redirect to other pages after opening for a few seconds
Just add the following code to achieve it.
Method 1: Using Meta
Usage: <Meta http-equiv=Refresh Content=30>
<Meta http-equiv="Refresh" Content="5; Url=http://sc.jb51.net">
The first statement is to stay for 30 seconds and automatically refresh, and the second one is to stay for 5 seconds and redirect to sc.jb51.net. Use them separately to achieve automatic refresh or automatic steering functions.

The second method: js implementation
setTimeout(function(){window.location.href = 'http://sc.jb51.net';},2000)
The third js code with countdown

Copy code
The code is as follows:

<html>
<head>
<title>Jump after 10 seconds</title>
</head>
<body>
<input type="text" readonly="true" value="10" id="time">
</body>
<script language="javascript">
var t = 10;
var time = document.getElementById("time");
function fun(){
t--;
time.value = t;
if(t<=0){
location.href = "https://www.jb51.net";
clearInterval(inter);
}
}
var inter = setInterval("fun()",1000);
</script>
</html>

The page jump function can of course be implemented using js, but the advantage of the above code is that it can also be used when the browser does not support js. If you want to achieve a real-time countdown effect, you need to use js to implement it. Generally, you can combine the two to make a judgment.
javascript page jump method collection page jump code implemented using meta

<<:  Detailed explanation of vue-router 4 usage examples

>>:  Detailed tutorial on installing CentOS, JDK and Hadoop on VirtualBox

Recommend

How to set up vscode remote connection to server docker container

Table of contents Pull the image Run the image (g...

Implementation steps for docker deployment lnmp-wordpress

Table of contents 1. Experimental Environment 2. ...

How to implement the webpage anti-copying function (with cracking method)

By right-clicking the source file, the following c...

A brief discussion on the characteristics of CSS float

This article introduces the characteristics of CS...

Vue implements online preview of PDF files (using pdf.js/iframe/embed)

Preface I am currently working on a high-quality ...

JS implements the snake game

Table of contents 1. Initialization structure 2. ...

Vue integrates Tencent Map to implement API (with DEMO)

Table of contents Writing Background Project Desc...

Detailed explanation of how to write mysql not equal to null and equal to null

1. Table structure 2. Table data 3. The query tea...

Analysis of the causes of accidents caused by Unicode signature BOM

Maybe you are using include files here, which is u...

Example code for using Nginx to implement 301 redirect to https root domain name

Based on SEO and security considerations, a 301 r...

How does Vue implement communication between components?

Table of contents 1. Communication between father...

How to enable TLS and CA authentication in Docker

Table of contents 1. Generate a certificate 2. En...