Windows history.length property

  • Προηγούμενη σελίδα go()
  • Επόμενη σελίδα back()
  • Επιστροφή στο προηγούμενο επίπεδο Window History

Definition and usage

length The property returns the number of URLs in the current browser window history list.

This property returns at least 1, because the list includes the current page.

This property is very useful for finding out how many pages the user has visited in the current browsing session.

Tip:history.back() Valid only if there is a previous page in the history list.

See also:

history.back() method

history.forward() method

history.go() method

Example

Get the number of URLs in the history list:

let length = history.length;

Try it yourself

Syntax

history.length

Parameter

None.

Return value

Type Description
Number The number of entries in the history list.

Υποστήριξη περιηγητών

Όλοι οι περιηγητές υποστηρίζουν history.length

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη
  • Προηγούμενη σελίδα go()
  • Επόμενη σελίδα back()
  • Επιστροφή στο προηγούμενο επίπεδο Window History