The window. history Object does not use the window prefix when writing. To protect user privacy, the methods for accessing this object by JavaScript are limited.
Method:
History. back ()-load the previous URL in the history list, which is the same as clicking the forward button in the browser.
History. forward ()-load the next URL in the history list, which is the same as clicking the forward button in the browser.
Instance:
Copy codeThe Code is as follows:
<Html>
<Button name = "back" value = "back" onclick = "goBack ()"> back </button>
<Button name = "forward" value = "forward" onclick = "goForward ()"> forward </button>
<Script type = "text/javascript">
Function goBack (){
History. back ();
}
Function goForward (){
History. forward ();
}
</Script>
</Html>
Other methods:
Copy codeThe Code is as follows:
History. go (0); // refresh the current page
// The following information must be recorded in the browser, otherwise it will not work.
History. go (1); // Previous Page
History. go (-1); // return a page
History. go (-2); // two back pages
History. length; // number of historical records contained in the current window