The Back Button

All browsers in common use have a Back button on the navigation bar. The browser maintains a list of recently visited pages in memory and allows you to step back through these to revisit pages you have recently seen.

Users have become used to the Back button as a standard part of the surfing experience, just as they have with the other facets of the page-based web paradigm.

Ajax, as you have learned, does much to shake off the idea of web-based information being delivered in separate, page-sized chunks; with an Ajax application, you may be able to change page content over and over again without any thought of reloading the browser display with a whole new page.

Tip

 

JavaScript has its own equivalent of the Back button written into the language. The statements

onClick = "history.back()"

and

onClick = "history.go(-1)"

both mimic the action of clicking the Back button once.

 

 

 

What then of the Back button?

This issue has caused considerable debate among developers recently. There seem to be two main schools of thought:

 

Artificially re-creating former states is indeed possible but adds a great deal of complexity to Ajax code and is therefore somewhat the province of the braver programmer!

Although the latter option sounds a bit like it's trying to avoid the issue, it does perhaps have some merit. If you use Ajax to re-create desktop-like user interfaces, it's worthy of note that desktop applications generally don't haveor needa Back button because the notion of separate "pages" never enters the user's head!