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
| 123456 |
<head><!-- 以下方式只是刷新不跳转到其他页面 --><metahttp-equiv="refresh" content="10"><!-- 以下方式定时转到其他页面 --><metahttp-equiv="refresh" content="5;url=hello.html"> </head> |
Advantages: Simple
Cons: Not available in Struts tiles
2) Implementation of JavaScript
| 123456 |
< Code class= "JavaScript plain" ><script language= "javascript" type= "Text/javascript" > //direct jump ' hello.html ' ; //The following way to a timed jump settimeout ( </SCRIPT> |
Advantages: Flexible, can combine with more other functions
Cons: Affected by different browsers
3) combined with a reciprocal JavaScript implementation (IE)
| 123456789 |
< span id=" Totalsecond ">5</ span > < script language= " JavaScript "type=" Text/javascript "> var second = Totalsecond.innertext; setinterval ("redirect ()", +); function redirect () { totalsecond.innertext=--second; if (second< 0 } </SCRIPT> |
Advantages: More Humane
Cons: Firefox does not support (Firefox does not support innertext attributes for span, Div, etc.)
3 ') combined with a countdown to the JavaScript implementation (Firefox)
| 123456789 |
<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 = ‘hello.html‘; } </script> |
4) solve the problem that Firefox does not support innertext
| 12345678 |
<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> |
5) Integration 3) and 3 ')
| 123456789101112131415161718192021222324 |
<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 = ‘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