history
object length by using:
It will return the number of browsing session history.
In other browsers other than Internet Explorer (less than or equal to 9 version, maybe) genre, the current page is also added as a history object element. Thus, it will return
1
even though we have nowhere to go to.(Old) Internet Explorer will return
0
if you have no other page to go to (previous/next).The new Internet Explorer (10 - 11) behaves like the other ones now. More of Chrome-like looks.
If we flush/empty the
browsing history
, then it will also reset the amount of length of history.No returned value
For security reason, this object doesn't return any value, except the
read-only
length.
Methods
The (cross-browser) available methods are:
back()
Action:
the current window will change state to the previous page if the previous page exists.
Example:
This has no returned value.history.back()
forward()
Action:
the current window will change state to the next page if the next one exists in the object.
Example:
This has no returned value.history.forward()
go(integer)
Action:
can go back or forward.
Examples:-
history.go(-1)
is equivalent withhistory.back()
-
history.go(1)
is equivalent withhistory.forward()
If the integer we put is out of bound, the method will return nothing (no error).-
Doodle
I made an animation with the JavaScript itself to capture and show your browser
history.length
below.
Link for further exploration
- Window.history at Mozilla Developers Network
- Independent page of the doodle at Thor
Updated Nov 17, 2014
No comments
Post a Comment