user1535467
user1535467

Reputation: 61

alternative in disabling back button in any browser

Is there any alternative on disabling back buttons of any browser to avoid the following situation:

  1. The user is filling out a large form
  2. The user accidentally presses the back button
  3. When the user returns to the page they have to being filling out the form again as the form has been wiped

Upvotes: 3

Views: 395

Answers (2)

Jason Sperske
Jason Sperske

Reputation: 30446

Check out sisyphus.js. it is exactly for this purpose. It adds GMail style (client side) auto saving to any HTML form. Add this line of JavaScript in the page with the form you want to save:

$('form').sisyphus();

As the user fills in this form the library will automatically save anything they type, locally. If they leave the page (or the browser crashes, just returning to the same page will auto populate the form with all of their data. As soon as they successfully submit the form, sisyphus.js will clear out the locally cached inputted data.

There is an alternative to Sisyphus that I have not tried yet called Garlic.js which is said to have better support for older browsers.

Upvotes: 3

Chandermani
Chandermani

Reputation: 42669

You need to track some dirty flag on the form. Browsers have a onbeforeunload event. Subscribe to this event and popup a dialog to user whether he really wants to leave the page.

Keep in mind this event gets fired for any navigation from the page.

Upvotes: 0

Related Questions