tags:

views:

352

answers:

3

Is there a way to make the user's back button on their browser, call a javascript function instead of going back a page?

A: 

Yes, have a look at these discussions.

Cade Roux
+5  A: 

You can't override the behaviour that if a user follows a link to your page, clicking Back will take them off it again.

But you can make JavaScript actions on your page add entries into the history as though they were clicks to new pages, and control what happens with Back and Forward in the context of those clicks.

There are JavaScript libraries to help with this, with Really Simple History being a popular example.

RichieHindle
+1  A: 

I already hate your website/app and I don't even know what it is.

DancesWithBamboo
I'm weak. Couldn't resist to upvote. xD
Arnis L.
A good AJAX application needs to control the Back button. Why do you think I can click on an email in my Gmail inbox and then click Back to return to the Inbox?
RichieHindle
Not helpful DancesWithBamboo. I need to do exactly what RichieHindle is talking about. I am trying out the Really Simple History script. I will let everyone know how it turns out.
Will Ayers