The javascript history object of history USES the method of of to enable the browser to move forward and backward

  • 2020-03-30 01:15:16
  • OfStack

The window.history object is not written with the prefix window. To protect user privacy, JavaScript access to this object is restricted.

Methods:

History.back () - loads the previous URL in the history list, which is the same as clicking the forward button in the browser
History.forward () - loads the next URL in the history list, which is the same as clicking the forward button in the browser

Example:


<html>
<button name="back" value=" back " onclick="goBack()"> back </button>
<button name="forward" value=" forward " onclick="goForward()"> forward </button>
<script type="text/javascript">
function goBack(){
        history.back();         
}
function goForward(){
        history.forward();      
}       
</script>
</html>

Other methods:


Related articles: