Jump to content

Tracking browser navigation direction history with JS


ghostcoder

Recommended Posts

Ok, I'm using pushState, replaceState and popstate events along with Ajax to change content on a new project I'm working on. The basics are very simple and I've finally got it working well.

 

However, I need to find a way to track and determine when a user is moving forward or back through the browser history, so that I can adjust the transitions properly. In my case, if someone goes back, I want the transition to be left to right, otherwise, right to left.

 

I'm thinking the only way might be in a cookie. The system needs to remember history even if the person backs out of the site. ( as in, if you first load phpfreaks.com and the navigate to a site, move around a bit and then use the back button to go back to phpfreaks. Then, you may decide to click forward again to the site.

 

Does anyone have any ideas on the easiest way to do this? Keeping some sort of array in a cookie, maybe?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.