Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods of JavaScript History object

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What are the methods of JavaScript History object? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

The window.history object contains the browser history. Visitors can usually use the browser's forward and back buttons to access pages they have visited before. JavaScript's history object records the pages that users have visited, and enables browsers to navigate forward and backward in a similar way.

What are the methods of JavaScript History object

You can go back one page through the back function, one page forward through the forward function, or arbitrarily back or forward pages using the go function, and you can view the number of pages stored in the history object through the length property.

Note:

The history page URL in the history object cannot be displayed for security reasons.

If a form has not been viewed by the user on any page (that is, a new form), its history object cache URL is empty and cannot be navigated using related functions.

Methods and properties of the history object

Method / property description

Go () forward or backward the specified number of pages

Back () steps back one page, which is the same as the browser's back button.

Forward () moves forward one page, which is the same as the browser's forward button.

How many URL are cached in the length history object

A description of the go () method.

What are the methods of JavaScript History object

Syntax:

History.go (x)

Where x (integer) is the number of pages forward or backward.

X > 0: forward x pages

X 0: back-x pa

X = 0: refresh the current page.

For example, move forward one page:

?

one

History.go (1); / / same as history.forward ()

Back up one page:

?

one

History.go (- 1); / / same as history.back ()

Refresh the current page

?

one

History.go (0); / / same as location.reload ()

This is the end of the answers to the questions about the methods of JavaScript History objects. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report