Flash Player 通知浏览器正在关闭 ++
我已经实现了 Flex / js 逻辑,以在用户尝试导航离开我的应用程序(例如关闭浏览器、点击后退按钮等)时提示用户 此处。这效果很好,我对结果非常满意。最近出现的一个简单问题是如何从我的 Flex 应用程序内部捕获“用户在 js 弹出窗口上按下确定,并且实际上正在离开页面”事件,以便了解用户何时实际离开页面。我认为逻辑是相似的,但不幸的是我不会说 js,因此陷入困境。任何帮助将不胜感激。
谢谢你!
I've implemented the Flex / js logic to prompt the user when they try to navigate away from my app (e.g. close browser, hit back button, etc) described here. This works great and I've been super happy with the results. One quick question that recently came up is how to capture the "user pressed ok on the js popup and is in fact leaving the page" event from inside my flex app, in order to know when the user actually left the page. I assume the logic is similar, but unfortunately I do not speak js and am thus stuck. Any help would be greatly appreciated.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
onbeforeunload 的目的不是为了在用户选择说“是的,让我离开”时为您提供额外的时间来浏览该页面 - 您无法对用户关闭页面的信息进行任何操作。您可以告诉 Flash 该函数已运行,并可能对此执行一些操作,具体取决于用户按“确定”的速度,但我相信仅此而已。
onbeforeunload is not designed to give you additional time with the page if the user chooses to say "yes, let me leave" - there's nothing you could do with the information that the user did close the page. You can tell Flash that the function ran, and possibly do something with that, depending on how fast the user presses 'ok' but I believe that's about it.
提示函数的结果应该是文本字段的值。
虽然,您无法阻止浏览器关闭/卸载(安全),但在卸载开始之前您将有一点时间。因此,您可以在这里进行有限的数据管理,但是,不建议这样做,并且数据可能/将会丢失。
如果您这样做只是为了提醒用户您认为他们应该留在您的网站上,您可能需要重新考虑这一点,因为它是最烦人的,并且会导致您失去更多用户。
The result of the prompt function should be value of the text field.
Although, you can not keep the browser from closing/unloading(security) you will have a little bit of time before the unload starts. So you could do limited data management here however, it is not recommended and data can/will be lost.
If you are doing it just to remind the user that you think they should stay at your site, you might want to reconsider this as it is most annoying and will cause you to loose more users.
好吧,我想我找到了答案 - 我认为连接 onunload 可以解决问题,因为它可以让我辨别页面的实际偏离和尝试的偏离。感谢 Erik Bakker 在此帖子中的回答(已投票!)。
谢谢大家的
帮助
Ok, I think I found my answer - I think hooking up onunload will do the trick, as it'll let me discern between actual departures from the page and attempted ones. Thank you to Erik Bakker for his answer in this thread (upvoted!).
thank you all for your help
f