html can't do it301 jumpYes, but it can be passed
After 5 seconds, it will automatically jump to the hello.html file in the same directory (modify it according to your own needs).
The following are five examples to illustrate in detail, the main function of these examples is: after 5 seconds, automatically jump to the hello.html (modify according to your own needs) files in the same directory.
1) HTML implementation <head> <!-- The following way is just refreshed without jumping to other pages --> <meta http-equiv="refresh" content="10"> <!-- Go to other pages regularly by --> <meta http-equiv="refresh" content="5;url=hello.html"> </head>
Pros: Simple Cons: Not available in Struts Tiles 2) JavaScript implementation <script language="javascript" type="text/javascript"> The following method jumps directly window.location.href='hello.html'; The following is a regular jump setTimeout("javascript:location.href='hello.html'", 5000); </script>
Pros: Flexible, can combine more other functions Cons: Affected by different browsers
3) javascript implementation with inverse countdown (IE) <script language="javascript" type="text/javascript"> var second = document.getElementByIdx_x('totalSecond').textContent; setInterval("redirect()", 1000); function redirect()
{ document.getElementByIdx_x('totalSecond').textContent = --second; if (second < 0) location.href = 'hello.html';
} </script>
Pros: More user-friendly Disadvantages: firefox does not support (firefox does not support innerText attributes for span, div, etc.)
3') incorporates the reciprocal javascript implementation (Firefox) <span id="totalSecond">5</span> <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>
4) Fix the issue that Firefox does not support innerText <span id="totalSecond">5</span> <script language="javascript" type="text/javascript"> if(navigator.appName.indexOf("Explorer") > -1){ document.getElementByIdx_x('totalSecond').innerText = "my text innerText"; } else{ document.getElementByIdx_x('totalSecond').textContent = "my text textContent";
} </script>
5) Integration 3) and 3')
<span id="totalSecond">5</span>
<script language="javascript" type="text/javascript"> var second = document.getElementByIdx_x('totalSecond').textContent;
if (navigator.appName.indexOf("Explorer") > -1) { second = document.getElementByIdx_x('totalSecond').innerText; } else { second = document.getElementByIdx_x('totalSecond').textContent;
}
setInterval("redirect()", 1000); function redirect() { if (second < 0) { location.href = 'hello.html'; } else { if (navigator.appName.indexOf("Explorer") > -1) { document.getElementByIdx_x('totalSecond').innerText = second--; } else { document.getElementByIdx_x('totalSecond').textContent = second--; }
}
} </script>
|