This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12922|Reply: 0

[Website Building Knowledge] html 301 jump html how to do jumps

[Copy link]
Posted on 10/26/2014 5:19:00 PM | | |
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>






Previous:Perfect for shields, safe dogs
Next:Chapters 2, 4, 5, 6, and 7 of the "Hopu Company" Java courseware in the first semester of freshman year
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com