在刷新时阻止浏览器。 [英] Block browser in refresh time.

查看:113
本文介绍了在刷新时阻止浏览器。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用代码,但默认的msg警告仅显示为您所做的更改可能无法保存。刷新我的页面当时如何在浏览器中显示我自己的评论显示提醒。



我尝试过:



I am using the code but default msg alert only display like"Changes you made may not be saved". Refresh my page that time how to display my own comments display alert in my browser.

What I have tried:

$(window).on('beforeunload', function () { return 'Please Stay On This Page'; });

推荐答案

(窗口).on('beforeunload',function(){返回'请留在此页';});
(window).on('beforeunload', function () { return 'Please Stay On This Page'; });


如果我正确理解您的问题,您想要做的是自定义您所做的更改可能不是保存的消息。



现在这被认为是安全问题,并且由于能够以恶意方式自定义消息,因此不再允许这样做。



WindowEventHandlers.onbeforeunload - Web APIs | MDN [ ^ ]



javascript - 如何显示你是你确定要离开这个页面吗?什么时候改变? - 堆栈溢出 [ ^ ]
If i understand your question correctly, what your wanting to do is customize the "Change you've made may not be saved message".

This is now considered a security issue and is no longer allowed given the ability to customize the messages in a malicious way.

WindowEventHandlers.onbeforeunload - Web APIs | MDN[^]

javascript - How to show the "Are you sure you want to navigate away from this page?" when changes committed? - Stack Overflow[^]


这篇关于在刷新时阻止浏览器。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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