验证关闭的网页 [英] Validating a closing webpage

查看:65
本文介绍了验证关闭的网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要让我评估当用户试图关闭某个网页时是否应该关闭该网页的代码.我知道onunload事件,但是我想这样做而不刷新页面.

I want code that allows me to evaluate if a web page should be allowed to close, when the user tries to close it. I know about the onunload event, but I want to do this without refreshing the page.

推荐答案

如果您阅读 ^ ],您将看到使用unload事件是不可靠的.如果您完全可以启动它,那么如果您不想让用户离开它,则可以使用条件逻辑来重新加载您的页面.但是,这是可怕的用户界面.如果您的用户决定关闭您的页面,则应让他们使用,并以另一种方式来解决他们所拥有的事实.据我所知,unload事件不允许您停止页面加载,这就是为什么要停止页面必须重新加载页面的原因.当然,如果他们关闭浏览器,您将无能为力.
If you read this[^], you''ll see that using the unload event is unreliable. If you''re able to get it to fire at all, then you can use conditional logic to reload your page if you don''t want to let the user leave it. This is, however, horrible UI. If your user decides to close your page, you should let them, and work out a different way to deal with the fact that they have. From what I can see, the unload event doesn''t allow you to stop the page loading, which is why you have to reload the page if you want to stop them. Of course, if they close the browser, there''s nothing you can do.


nooo
我只想知道他离开了页面
可以记录cookie并将其用于诊断刷新吗?
请帮我它很没意思
我们如何找到关闭与刷新之间的区别
nooo
just i want to know that he left the page
do we can record a cookie and use it for diagnosis the refresh?
plz help me its very imoprtant
how we can find difference between close and refresh


f11111111111111 f111111111111111 f111111111111111111111:((:(((
f11111111111111 f111111111111111 f111111111111111111111 :(( :((


这篇关于验证关闭的网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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