Implementation of Automatic jump of jsp pages

Source: Internet
Author: User

Function: automatically uploads the 02view.html file under the same directory in 5 seconds.
 
1) html implementation
<Head>
<Meta http-equiv = "refresh" content = "5366url%02view.html">
</Head>
Advantage: simple
Disadvantage: cannot be used in Struts Tiles
 
2) javascript implementation
<Script language = "javascript" type = "text/javascript">
SetTimeout ("javascript: location.href='02view.html '", 5000 );
</Script>
Advantage: flexible, can be combined with more other functions
Disadvantage: affected by different browsers
 
3) combined with the countdown javascript implementation (IE)
<Span id = "totalSecond"> 5 </span>
<Script language = "javascript" type = "text/javascript">
Var second = totalSecond. innerText;
SetInterval ("redirect ()", 1000 );
Function redirect (){
TotalSecond. innerText = -- second;
If (second <0) location.href%'02view.html ';
}
</Script>
Advantage: more user-friendly
Disadvantage: firefox does not support (firefox does not support innerText attributes such as span and div)
 
3 ') combined with the countdown javascript implementation (firefox)
<Script language = "javascript" type = "text/javascript">
Var second = document. getElementById ('totalsecond'). textContent;
SetInterval ("redirect ()", 1000 );
Function redirect ()
{
Document. getElementById ('totalsecond'). textContent = -- second;
If (second <0) location. href = '02view.html ';
}
</Script>
4) solve the problem that Firefox does not support innerText.
<Span id = "totalSecond"> 5 </span>
<Script language = "javascript" type = "text/javascript">
If (navigator. appName. indexOf ("Explorer")>-1 ){
Document. getElementById ('totalsecond'). innerText = "my text innerText ";
} Else {
Document. getElementById ('totalsecond'). textContent = "my text textContent ";
}
</Script>
5) integration 3) and 3 ')
<Span id = "totalSecond"> 5 </span>
<Script language = "javascript" type = "text/javascript">
Var second = document. getElementById ('totalsecond'). textContent;
If (navigator. appName. indexOf ("Explorer")>-1)
{
Second = document. getElementById ('totalsecond'). innerText;
} Else
{
Second = document. getElementById ('totalsecond'). textContent;
}

SetInterval ("redirect ()", 1000 );
Function redirect ()
{
If (second <0)
{
Location. href = '02view.html ';
} Else
{
If (navigator. appName. indexOf ("Explorer")>-1)
{
Document. getElementById ('totalsecond'). innerText = second --;
} Else
{
Document. getElementById ('totalsecond'). textContent = second --;
}
}
}
</Script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.