5 methods for HTML page Jump
The following five examples are provided to describe in detail. The main functions of these examples are as follows: in five seconds, the hello.html file under the same directory will be automatically uploaded (as needed.
1) html implementation
Advantage: simple
Disadvantage: cannot be used in Struts Tiles
2) javascript implementation
<Script language = "javascript" type = "text/javascript"> // use the following method to directly redirect setTimeout ("javascript: location.hrefout 'hello.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)
5<script language="javascript" type="text/javascript"> var second = totalSecond.innerText; setInterval("redirect()", 1000); function redirect(){ totalSecond.innerText=--second; if(second<0) location.href='hello.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 = 'hello.html'; } </script>
4) solve the problem that Firefox does not support innerText.
5<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 ')
5<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>