Today, I learned a new technology, that is, when I click "Submit" or "Confirm" on a page, it will automatically jump to a page.
I searched the internet and found that there are many ways to handle this technology. I only wrote down three of the methods I learned in the video:
1. Use response. sendRedirect ("target page. jsp \. htm;
2. Sometimes we need a prompt, such as "automatically jump after x seconds. If no jump is made, click here". In myeclipse, you can call Delay Go To URL in Snippets. the following code is automatically generated:
Copy codeThe Code is as follows:
<Script language = "JavaScript1.2" type = "text/javascript">
<! --
// Place this in the 'head' section of your page.
Function delayURL (url, time ){
SetTimeout ("top. location. href = '" + url + "'", time );
}
// -->
</Script>
<! -- Place this in the 'body' section -->
<A href = "javascript:" onClick = "delayURL('myPage.html ', '000000')"> My Delayed Link </a>
Modify this code:
Copy codeThe Code is as follows:
<Script language = "JavaScript1.2" type = "text/javascript">
Function delayURL (url, time ){
SetTimeout ("top. location. href = '" + url + "'", time );
}
</Script>
<Span id = "time" style = "background: red"> 3 </span>
Automatic jump in seconds. If no jump is made, click the following link.
<A href = "target page. jsp"> Target page </a>
<Script type = "text/javascript">
DelayURL ("http://www.hualai.net.cn", 3000 );
</Script>
Then, the system will jump to the "target page" in 3 seconds ". In this way, the page will not change when the jump is set for a few seconds, for example, set 3 seconds, and then change 3 to 2 as time changes, and then change to 1 until the jump is made, see the third method below.
3. modify the code in method 2:
Copy codeThe Code is as follows:
<Script language = "JavaScript1.2" type = "text/javascript">
Function delayURL (url ){
Var delay = document. getElementById ("time"). innerHTML;
// The final innerHTML cannot be lost; otherwise, delay is an object.
If (delay> 0 ){
Delay --;
Document. getElementById ("time"). innerHTML = delay;
} Else {
Window. top. location. href = url;
}
SetTimeout ("delayURL ('" + url + "')", 1000 );
// 1000 milliseconds, that is, jump every second
}
</Script>
<Span id = "time" style = "background: red"> 3 </span>
Automatic jump in seconds. If no jump is made, click the following link.
<A href = "target page. jsp"> topic list </a>
<Script type = "text/javascript">
DelayURL ("http://www.hualai.net.cn/news/knowledge/265.html ");
</Script>
The effect of this method is to jump to the target page after clicking submit on the previous page and jump to this page after 3 seconds (this 3 will be reduced to 0.