Avatar of ggray1970
 asked on

help with history object

I am very new to javascript and have written a very simple code displaying the number of pages stored in the history object.  My problem is that no matter how many times I leave and return or refresh, the number stays at 1?  I need it to update automatically when I movbe to another page and then return.

document.write("Number of pages currently visited: " + history.length);


Please help or direct me to where I may find the answer.

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

your code run fine
if you click to a link in your page and come back it, you don't add a new history

I was using the browser back buttons to return to the page.  When retyping the site in the address bar the count automatically updated.  I told you I was NEW to Javascript.  Thanks a lot man!

LOL.  No problem.  I'm happy to assist.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy