从网页导航离开时,警报

编程入门 行业动态 更新时间:2024-10-10 03:22:31
本文介绍了从网页导航离开时,警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我尝试关闭未保存的更改我的谷歌文档选项卡上,这是我在我的浏览器(FF 3.5)获得。

When I try to close my Google docs tab with unsaved changes, this is what I get in my browser (FF 3.5).

您确定要离开  从这个页面?

Are you sure you want to navigate away from this page?

您在这个未保存的更改  文件。点击立即取消,那么  保存来拯救他们。现在就点击确定  丢弃它们。

You have unsaved changes in this document. Click Cancel now, then 'Save' to save them. Click OK now to discard them.

preSS确定继续,或取消  留在当前页面。

Press OK to continue, or Cancel to stay on the current page.

我的问题是这样的警报是否是Web应用程序(gdocs为如)的一部分,或者它们是由浏览器给出了?如果后者,这是怎么做的?

My question is whether such alerts are part of the web app (gdocs for eg.) or are they given out by the browser? If latter, how is this done?

推荐答案

浏览器。这是 beforeunload 事件处理函数返回的对话框,这是只有三段的中间的自定义文本 - 其他两款,以及按钮的文字不能定制或以其他方式改变了。

By the browser. It's the beforeunload event handler that returns the customized text of the dialog, which is only the middle of the three paragraphs - the other two paragraphs as well as the text of the buttons cannot be customized or otherwise changed.

window.onbeforeunload = function(){ return 'Testing...' }

将产生一个对话框,说:

Will yield a dialog that says

Are you sure you want to navigate away from this page? Testing... Press OK to continue, or Cancel to stay on the current page.

您可以通过设置处理器为null抵消这种

You can nullify this by setting the handler to null

window.onbeforeunload = null;

更多推荐

从网页导航离开时,警报

本文发布于:2023-11-27 18:52:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639197.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   网页

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!