Home >Web Front-end >HTML Tutorial >[HTML] 5 ways to jump to Html pages
Directory structure:
contents structure [-]
html implementation
Javascript implementation
Combined reciprocal javascript implementation (IE)
Solve the problem that Firefox does not support innerText
Combined the reciprocal javascript implementation (IE, Firefox)
Reference article
Five examples are listed below to explain in detail. The main functions of these examples are: after 5 seconds, automatically jump Go to the hello.html file in the same directory (modify it according to your needs).
1) Implementation of html
<head> <!-- 以下方式只是刷新不跳转到其他页面 --> <meta http-equiv="refresh" content="10"> <!-- 以下方式定时转到其他页面 --> <meta http-equiv="refresh" content="5;url=hello.html"> </head>
Advantages: Simple
Disadvantages: Cannot be used in Struts Tiles
2) Implementation of javascript
57916d668bd9fde2bda8a8d63055ad35 // 以下方式直接跳转window.location.href='hello.html';// 以下方式定时跳转setTimeout("javascript:location.href='hello.html'", 5000); 2cacc6d41bbb37262a98f745aa00fbf0
Advantages: Flexible, can be combined with more other functions
Disadvantages: Affected by different browsers
3) Combined Reciprocal javascript implementation (IE)
7b27906f4f08ef4a2c36759443f86ada554bdf357c58b8a65c66d7c19c8e4d114 57916d668bd9fde2bda8a8d63055ad35 second ="redirect()", 1000=--(second<0) location.href='hello.html'2cacc6d41bbb37262a98f745aa00fbf0
Advantages: more user-friendly
Disadvantages: not supported by firefox (firefox The innerText attributes of span, p, etc. are not supported)
3') Combined with the javascript implementation of the reciprocal (firefox)
57916d668bd9fde2bda8a8d63055ad35 var second = document.getElementById('totalSecond').textContent; setInterval("redirect()", 1000); function redirect() { document.getElementById('totalSecond').textContent = --second; if (second < 0) location.href = 'hello.html'; } 2cacc6d41bbb37262a98f745aa00fbf0
4) Solve the problem that Firefox does not support innerText
7b27906f4f08ef4a2c36759443f86ada554bdf357c58b8a65c66d7c19c8e4d11457916d668bd9fde2bda8a8d63055ad35 if(navigator.appName.indexOf("Explorer") > -1){ document.getElementById('totalSecond').innerText = "my text innerText"; } else{ document.getElementById('totalSecond').textContent = "my text textContent"; } 2cacc6d41bbb37262a98f745aa00fbf0
5) Combined with reciprocal javascript implementation (IE, Firefox)
7b27906f4f08ef4a2c36759443f86ada554bdf357c58b8a65c66d7c19c8e4d114 57916d668bd9fde2bda8a8d63055ad35 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 8207cfcd3817cc3a3cfbc225f03e6e03 -1) { document.getElementById('totalSecond').innerText = second--; } else { document.getElementById('totalSecond').textContent = second--; } } } 2cacc6d41bbb37262a98f745aa00fbf0
For more [HTML] 5 ways to jump to Html pages and related articles, please pay attention to the PHP Chinese website!