JavaScript Window History, javascripthistory

Source: Internet
Author: User

JavaScript Window History, javascripthistory
The window. history object contains the browser history.

Window History

Window. historyObjects can be written without the window prefix.

To protect user privacy, the methods for accessing this object by JavaScript are limited.

Some methods:

  • History. back ()-same as clicking the back button in the browser
  • History. forward ()-same as clicking the button in the browser to forward
Window History Back

The history. back () method loads the previous URL in the history list.

This is the same as clicking the back button in the browser:

Instance

After the button is created on the page:

<Html>
<Head>
<Script>
Function goBack ()
{
Window. history. back ()
}
</Script>
</Head>
<Body>

<Input type = "button" value = "Back" onclick = "goBack ()">

</Body>
</Html>

The above code is output:


Window History Forward

The history forward () method loads the next URL in the history list.

This is the same as clicking the forward button in the browser:

Instance

Create a forward button on the page:

<Html>
<Head>
<Script>
Function goForward ()
{
Window. history. forward ()
}
</Script>
</Head>
<Body>

<Input type = "button" value = "Forward" onclick = "goForward ()">

</Body>
</Html>

The above code is output:

 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.