Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果页面已提交,我想编写防止用户单击按钮的方法,如下所示:
大佬们有什么解决办法吗?谢谢你的时间
我过去用过这个
$(window).focusout(function({$(window).focusin(function({$(window).off('focusout');location.reload();})});
这在非常基本的情况下并不适合每个用例,因为每当用户失去/获得窗口焦点时,它总是会强制刷新。您可以将一些信息保存到浏览器的本地存储中,以保存/检查用户是否在页面上执行了提交,然后仅在提交时重新加载页面。