开发者

Flash Player notified that browser is closing ++

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 apprecia开发者_Go百科ted.

Thank you!


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.

<script type="text/javascript">
  var answer = prompt ("What is your name ?","")
  alert ("Hello there, " + answer)
</script> 


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜