如何从回去prevent浏览器/转发的历史时,水平滚动? [英] How to prevent a browser from going back/forward in history when scrolling horizontally?

查看:113
本文介绍了如何从回去prevent浏览器/转发的历史时,水平滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何才能禁止使用JQuery或者JS原住民现代浏览器的默认功能为去向前或向后水平滚动时?

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

这使用触控板时滚动到可滚动div的结束或开始时通常发生。

This usually happens when using a trackpad and when scrolled to the end or start of a scrollable div.

推荐答案

所以我想既然我已经创建了一个Web应用程序,为什么不提示将从丢失任何未保存的更改或结束推迟用户的任何未保存的更改用户对了在浏览器历史上的previous或下一个页面。

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';
}; 

这篇关于如何从回去prevent浏览器/转发的历史时,水平滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆