Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to distinguish browser back / forward button?

Is it possible? even better, is it possible with jQuery?

I need to know whether use click back button or forward button so I can use page transition effect correctly, eg. slide from left - right if they hit forward and vice versa.

like image 952
Ken Vu Avatar asked Jan 23 '10 05:01

Ken Vu


People also ask

What is the back and forward button in browser?

Activating the back and forward buttons gives the user access to the previous page or the last page visited. They also provide a menu of the user's browsing history displaying the pages that have been visited.

What is the Back button on my browser?

A back button in the browser lets you back-up to the copies of pages you visited previously. The web browser's back and next buttons work well with web sites that provide information that changes infrequently, such as news and shopping web sites.

Where is my back and forward arrows on toolbar?

Please try this: right-click the + after the last tab and Customize... or View (Alt + V) > Toolbars > Customize. In this mode you can move the various items around and see if the arrow buttons are hidden behind other buttons or toolbars.


2 Answers

You can use the really simple history library

But if you want to handle it yourself, you can use the hash key (window.location.hash) by setting for instance the slide number there. When the user will click back or next the hash key will change, you detect it and make the change.

Unfortunately you have to check the change yourself, by setting an interval(i.e: 300ms) and check with the previous value. HTML5 has an onhashchange event.

like image 50
Mic Avatar answered Sep 21 '22 04:09

Mic


@David

Since browser back buttons don't track ajax requests, developers have no choice but to suppliment this lack of functionality. Using jquery we have to manually keep track of ajax requests and manually re-request the partial pages in order to give users what they WANT and EXPECT.

like image 26
LucidObscurity Avatar answered Sep 19 '22 04:09

LucidObscurity