5 ways to jump through HTML pages

Source: Internet
Author: User

Tags: NTS Navigator Highlight method Refresh else CTI struts Java

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 < span id=" Totalsecond ">5</ Span > < 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 ')

?
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

Related Article

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.

Tags Index: