MattsBits
MattsBits

MattsBits

Javascript - Forward & Back Button Functionality  

by Matt Hawkins, 16/04/2009
Categories : JavaScript

In order to replicate the forward and back button functionality you can use the following Javascript functions :

<script type="text/javascript">
<!--
function goBack() {
history.go(-1);
}
function goForward() {
history.go(1);
}
//-->
</script>


These can be used as required or you can create some HTML links :


<a href="javascript:history.go(-1);">Go back</a>
<a href="javascript:history.go(1);">Go Forward</a>


or some HTML buttons :

<form>
<input value="Back" onclick="history.go(-1); return true;" type="button">
<input value="Forward" onclick="history.go(1); return true;" type="button">
</form>


Author : Matt Hawkins  Last Edit By : Matt Hawkins
PHP Powered  MySQL Powered  Valid XHTML 1.0  Valid CSS  Firefox - Take Back The Web  EUKHost - Recommended Webhosting Solutions

MattHawkins CMS v3.0 - Copyright 2009-2022