How to prevent a browser from going back/forward in history when scrolling horizontally?

前端 未结 5 1898
长发绾君心
长发绾君心 2020-12-09 17:39

How can one disable a modern browsers default functionality using JQuery or Native JS for going backwards or forwards when scrolling horizontally?

This usually happe

5条回答
  •  生来不讨喜
    2020-12-09 18:06

    So I figured since i've created a web app, why not prompt the user for any unsaved changes which will defer the user from loosing any unsaved changes or ending up on the previous or next page in the browser history.

    Here is the solution if any one else comes across this problem like I did:

    window.onbeforeunload = function(e) {
        return 'Ask user a page leaving question here';
    }; 
    

提交回复
热议问题