Web Hosting Offers
See the new scripts recently added to Dynamic Drive. Click here.
Original, practical CSS codes and examples such as CSS menus for your site.
javascript tutorial Browse Basic JavaScript Tutorial
Browse JavaScript Script resources
Browse javascript FAQS
Categories:

javascript tutorial
buy template
Home >> Tutorials >> Advanced javascript tutorials

Javascript Button tips

Previous page and Next pageImage buttonAlert button
Prompt buttonScrolling buttonRotating button
Confirmation button  

Javascript Go Back to Previous Page /Go to Next Page Button Link
... 

Wondering how to create a back button or next button in your webpage? You can use JavaScript, functions Back, Forward for this.The following is the  code code for creating back and forward buttons.

<html>
<body>
<FORM NAME="testform">
<INPUT TYPE="button" VALUE="Prev Page" onClick="history.back();">
...
<INPUT TYPE="button" VALUE="Next Page" onClick="history.forward();">
</body>
</html>
 

Going back to more than one page ...
If you need to go back to 2 or more pages use the following code. Replace 'n"' with the number
pages you want to go back.

Eg:

Source Code:

<html>
<body>
<FORM NAME="testform">
<input TYPE="button" VALUE="Take me back to n pages" onClick="history.back(-n);">
</body>
</html>

Top

Graphic back and forward buttons

Do you want cool looking back and forward buttons? We can also create back and forward buttons by using image files.  (You can copy the  following image files.
Don't forget to keep both the buttons in the same directory as your html file)

backforward

Source Code:
<HTML>
<BODY>
<A HREF="javascript:history.back();">  <IMG BORDER = 0 SRC="prev.gif"></A>
<A HREF="javascript:history.forward();">
  <IMG BORDER = 0 SRC="next.gif"></A>
</BODY>
</HTML>

Top




Page contents: itechies.net - Learn how to add a JavaScript forward or back button to your HTML document.
javascript tutorial
javascript book
Buy this book