This method will always redirect to the user on the current page itself.
For example, user is on page 1 and there is a link on Page 1 which takes user to Page 2. Now when user clicks on the link, browser redirects the control to Page 2. Now from page 2 if user press back button of the browser then user will be redirect to the page 2 itself.
window.history contains the collection of the page visited by the user for particular browser session. As an alternative of window.history.forward(), one can also use window.history.go(+1). As both are same.
But if we want to display web page expired warning on the click of back button as we normally see in all banking sites? Actually what happens is, when you press the back button, browser takes the page from cache and display it on screen. So if we want to show web page expired warning, we should not allow the browser to cache the page. We can achieve this via ASP.NET.
protected void Page_Load(object sender, EventArgs e)
This code will not allow page to be cached. But one problem with this approach is that this will only work when there are some dynamic content in the page. i.e. change any drop down box value and then try to press back button.