In projects, we often encounter the function of automatically redirecting pages N seconds later. In fact, the method is very simple. The following section uses this article to share with you three common methods for automatic jump after the HTML page is 3 seconds, if you are interested in the knowledge about automatic jump to an html page 3 seconds later, let's take a look. In practice, we often encounter a problem: how can we automatically jump to a page N seconds later?
I have encountered problems and searched for information, and summarized three methods.
Method 1:
The simplest one: directly in frontAdd code:
The Code is as follows:
// Automatically redirects to res.html 3 seconds later. The two files belong to the same file. to jump to the jsp page, you need to enter the url address in the url ---- (the data written in the browser's address bar, for example: http: // localhost: 8080/TestDemo/1.jsp)
Method 2:
The method in window must be used:
SetTimeout calculates an expression after a specified millisecond value.
Example:
The Code is as follows:
Window. setTimeout ("alert ('hello, World')", 1000 );
This is written in js Code;
The specific implementation is as follows:
The Code is as follows: