-4

Is there any way to disable user from clicking browser's back/forward button until the currently accessed page is loaded completely.

Page being loaded completely need not refer to the API requests being made within the page. Simply looking if the browsers reload button is visible (and stop button is no more visible) is much appreciated.

I do not want to make use of history.forward() on back and such hacks. I want the back/forward buttons to look as if there is no history to navigate to, unless the current page is loaded completely.

I do not want to use browser extensions, and wanted to achieve this using javascript/jQuery itself.

I searched and could see that this is not possible. But, still wanted to see if any geeks have any new info to share. :(

anusreemn
  • 1,047
  • 1
  • 10
  • 24
  • Possible duplicate of [How to disable back button in browser using javascript](https://stackoverflow.com/questions/19926641/how-to-disable-back-button-in-browser-using-javascript) – Amr Elgarhy Aug 17 '17 at 13:48
  • and this: https://stackoverflow.com/questions/12381563/how-to-stop-browser-back-button-using-javascript – Amr Elgarhy Aug 17 '17 at 13:49
  • 2
    Possible duplicate of [how to stop browser back button using javascript](https://stackoverflow.com/questions/12381563/how-to-stop-browser-back-button-using-javascript) – chambo Aug 17 '17 at 13:49

1 Answers1

0

Try this. This might help you

$(window).bind('beforeunload', function(){
return 'Are you sure you want to leave?';

});

krishnar
  • 2,537
  • 9
  • 23