First show you the effect of the picture, if you feel good, please refer to the implementation code:
Web page Layout
<p> operation Success </p>
<strong>5</strong><span> seconds back to homepage </span><a href= "javascript : History.back (); > Return </a>
Task:
1. After opening the page, if you do not do anything to return to a new page
var num=document.getelementsbytagname ("Strong") [0].innerhtml;
Gets the element that displays the number of seconds, changing the number of seconds by the timer.
function count () {
num--;
document.getElementsByTagName ("Strong") [0].innerhtml=num;
if (num==0) {
location.assign ("www.imooc.com");
}
SetInterval ("Count ()", 1000);
2. Click Back to return to the previous page
function Backto () {
window.history.back ();
}
Location and history are objects in the window
The Location.assign () method is used to load a new document
The History.back () method can load the previous URL in the history list
The above is a small set for you to introduce the JavaScript based on the implementation of the Jump tips page, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!