The JavaScript history forward() method is used to navigate the browser forward to the next page in the history. It does not take any arguments and does not return a value.
Here are some examples of how the forward() method can be used in JavaScript code:
- To navigate the browser forward to the next page in the history, you can use the following code:
// navigate the browser forward to the next page in the history
history.forward();
- To navigate the browser forward to the next page in the history with a custom message, you can use the following code:
// navigate the browser forward to the next page in the history with a custom message
history.forward('Navigating forward to the next page...');
- To navigate the browser forward to the next page in the history and execute a callback function, you can use the following code:
// define a callback function
function onNavigateForward() {
// do something...
}
// navigate the browser forward to the next page in the history and execute the callback function
history.forward(onNavigateForward);
Overall, the forward() method provides a convenient way to navigate the browser forward to the next page in the history. It can be useful for tasks such as implementing a “forward” button or link, or for other operations that require navigating the browser forward to the next page in the history.
Leave a Reply