History Forward Page

forward function to go to next web page

Explanation

Methods or Function: forward()


forward() function is used in javscript to go to the next page in the history list. This does the same function as of next button in the browser window.
Code: history.forward();

Example:

To create a button that takes to the next page when users click on it using javascript.
Code:
<script language="javascript">
function gonext(){
history.forward();
}
</script>
<input type=button value="go next" onClick=gonext()>

Result:


To test this go to next web page, come back and do the testing
In the above example
a) we created a button
b) added an onClick event listener to the button.
c) when user clicks on the button the javascript function gonext()
will be invoked.
d) in the gonext() function we call history.forward().

Ask Questions

Ask Question