The following is a list of five examples in detail, the main function of these examples is: after 5 seconds, automatically jump to the same directory hello.html (according to their own needs to modify) files.
1) Implementation of HTML
<Head><!--The following methods just refresh do not jump to other pages -<Metahttp-equiv= "Refresh"content= "Ten"><!--go to another page in the following way -<Metahttp-equiv= "Refresh"content= "5;url=hello.html"> </Head>
Advantages: Simple
Cons: Not available in Struts tiles
2-1) JavaScript implementation [LOCATION.HREF]
<Scriptlanguage= "JavaScript"type= "Text/javascript"> //jump directly in the following wayswindow.location.href='hello.html';//The following methods are timed to jumpSetTimeout ("javascript:location.href= ' hello.html '", the); </Script>
The SetTimeout () method is used to call a function or evaluate an expression after a specified number of milliseconds.
Advantages: Flexible, can combine with more other functions
Cons: Affected by different browsers
2-2) combined with a reciprocal JavaScript implementation (IE)
<spanID= "Totalsecond">5</span><Scriptlanguage= "JavaScript"type= "Text/javascript"> varSecond=Totalsecond.innertext; SetInterval ("Redirect ()", +); functionRedirect () {Totalsecond.innertext=--second;if(Second<0) Location.href='hello.html'; } </Script>
The SetInterval () method invokes a function or evaluates an expression according to the specified period (in milliseconds).
The SetInterval () method keeps calling functions until Clearinterval () is called or the window is closed. The ID value returned by SetInterval () can be used as a parameter to the Clearinterval () method.
Advantages: More Humane
Cons: Firefox does not support (Firefox does not support innertext attributes for span, Div, etc.)
2-3) combined with the countdown to the JavaScript implementation (Firefox)
<Scriptlanguage= "JavaScript"type= "Text/javascript"> varSecond=document.getElementById ('Totalsecond'). textcontent; SetInterval ("Redirect ()", +); functionRedirect () {document.getElementById ('Totalsecond'). Textcontent= --second;if(Second< 0) Location.href= 'hello.html'; } </Script>
2-4) solve the problem that Firefox does not support innertext
<spanID= "Totalsecond">5</span><Scriptlanguage= "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>
2-5) compatible with reciprocal jumps for IE and FF
<spanID= "Totalsecond">5</span> <Scriptlanguage= "JavaScript"type= "Text/javascript"> varSecond=document.getElementById ('Totalsecond'). textcontent; if(Navigator.appName.indexOf ("Explorer") > -1) {Second=document.getElementById ('Totalsecond'). InnerText; } Else{Second=document.getElementById ('Totalsecond'). textcontent; } setinterval ("Redirect ()", +); functionRedirect () {if(Second< 0) {Location.href= 'hello.html'; } Else { if(Navigator.appName.indexOf ("Explorer") > -1) {document.getElementById ('Totalsecond'). InnerText=Second--; } Else{document.getElementById ('Totalsecond'). Textcontent=Second--; } } } </Script>
5 ways to jump through HTML pages