Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Event Handling

Making a <INPUT type=button> behave like the browser BACK button by jpbrassard
Posted: 15 Jul 03

This is one of the simpler things to do in JavaScript, but it's a good way of demonstrating how you can use the onclick event in various form elements to increase the functionality of your web page or application.

There are two ways to force the browser to go back to the previous page visited. These are detailed below.

<input type=button name=backButton id=backButton value="Back" onclick="javascript:history.go(-1)">

<input type=button name=backButton id=backButton value="Back" onclick="javascript:history.back">

Either one of those will act the same as the user clicking the back button on the browser. history.go is a little more powerful, because you can jump back more than one entry in JavaScript's history collection, but for most simple web pages, history.back will work just fine.

More info can be found at http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/history.html. DevEdge is a pretty good general resource for JavaScript stuff.


Back to Javascript FAQ Index
Back to Javascript Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close