window.back()

JavaScript1.2+, Jscript3.0 Nav4+, IE4+ Syntax

							window.back()

Description

The back() method of the Window object simulates the user clicking the Back button on the browser. It returns the browser's page or frame to the previous page or frame.

Example

Listing 7.526 has two buttons. One of the buttons takes the browser back one page and the other button takes it forward. Note that there has to be a back and previous page during your session for the button to have somewhere to go.

Listing 7.526 Using the back() Method
<html>
<body>
<form>
  <input type=BUTTON value="Back" onClick="window.back()">
  <input type=BUTTON value="Forward" onClick="window.forward()">
</form>
</body>
</html>
							
						

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.