onunload

Best way to detect browser closing/navigation to other page and do logout

旧街凉风 提交于 2019-11-30 13:18:01
I am writing an application in GWT and I need to detect when a user navigates away from my application or when he closes the browser window (onUnload event) and do a logout (session invalidation and few other cleanup tasks). The logout action is performed by a servlet. I am currently doing this by hooking into the onUnload() event and opening a new window pointed to the logout servlet. Is there a better way to do this? Any other suggestions are welcome. Looks like GWT does have an event for exactly this. ClosingEvent . Looks like you need to implement a ClosingHandler Why not just make a very

Best way to detect browser closing/navigation to other page and do logout

帅比萌擦擦* 提交于 2019-11-29 19:06:20
问题 I am writing an application in GWT and I need to detect when a user navigates away from my application or when he closes the browser window (onUnload event) and do a logout (session invalidation and few other cleanup tasks). The logout action is performed by a servlet. I am currently doing this by hooking into the onUnload() event and opening a new window pointed to the logout servlet. Is there a better way to do this? Any other suggestions are welcome. 回答1: Looks like GWT does have an event

Javascript onload and onunload

大城市里の小女人 提交于 2019-11-29 07:55:24
Consider the following HTML snippet containing some javascript utilizing prompt and unload . The prompt() method works fine but I want alerting something like Goodbye, user when reloading or leaving the page. Any help is greatly appreciated. <body onload="promptName()" > <script type="text/javascript"> function promptName() { var userName = prompt("What's your name ?", "") return userName; } function goodBye() { alert("Goodbye, " + promptName() + "!"); } window.onunload = goodBye(); </script> </body> You should write it like this: window.onunload = goodBye; Also, you might consider using the

cross-browser Onunload and Onbeforeunload ? (particularly opera 11)

纵饮孤独 提交于 2019-11-28 01:56:07
I have a form and I must notice user with alert() on exiting page while there are data in the form that had not been send. I've read that opera has a lot of problems with this. Opera 11 that is, because I need take into account only last version. So again, the alert should display on refresh, closing a tab, or closing whole browser. It would be nice to set event directly to the <form> element that would be launched on anything that leads to destroying this element. Opera does not yet support onbeforeunload. Opera's onunload support is incomplete - for example, it does not fire when you close a

Javascript onload and onunload

心已入冬 提交于 2019-11-28 01:49:07
问题 Consider the following HTML snippet containing some javascript utilizing prompt and unload . The prompt() method works fine but I want alerting something like Goodbye, user when reloading or leaving the page. Any help is greatly appreciated. <body onload="promptName()" > <script type="text/javascript"> function promptName() { var userName = prompt("What's your name ?", "") return userName; } function goodBye() { alert("Goodbye, " + promptName() + "!"); } window.onunload = goodBye(); </script>

Capturing result of window.onbeforeunload confirmation dialog

眉间皱痕 提交于 2019-11-27 23:40:23
Is there a way to capture to result of the window.onbeforeunload confirmation dialog like the one below from Stack Overflow (this happens when leaving the 'Ask Question' page without posting the question)? This is how it appears in Chrome, I believe it's slightly different in other browsers, but you always have some form of yes/no buttons. Presumably if they're still on the offending page after the event has been triggered they chose to stay and you could probably figure this out by watching the sequence of js. However I would like to know how to determine if they clicked "Leave this page" ? I

Is the onbeforeunload event not supported on iPhone?

早过忘川 提交于 2019-11-27 16:06:37
So, I've got a handy little bit of functionality in place in a jQuery Mobile app that lets the user know if he/she is navigating away from the page, as this will trigger a log off. In simplified form: $(window).bind('beforeunload', function() { return "Navigating away from this page will log you off. Are you sure you want to continue?"; }); $(window).unload(function() { logoff(); }); This works just great in both Safari and Chrome on my laptop. However, it doesn't appear to work on the iPhone simulator. Does the mobile browser included in iOS (I know it's Safari, but presumably a different

How to block pop-up coming from iframe?

我们两清 提交于 2019-11-27 08:55:24
I'm embedding page that has an exit pop-up. When you close the page, it automatically launches a pop-up window. How to disable pop-ups coming from the iframe on exit? If you are wanting to block something like POP up ads or something coming from a website you are showing in an IFRAME - it's fairly easy. Make a framefilter.php and javascriptfilter.php which your iframe points to. You can modify it to meet your needs such as the onload blah blah and etc. But as/is - it's been working fine for me for quite a while. Hope it helps. Replace your standard IFRAME HTML with this: <IFRAME SRC="http:/

Can I pop up a confirmation dialog when the user is closing the window in Safari/Chrome?

谁说我不能喝 提交于 2019-11-27 02:15:50
In IE and FF, i can attach an event handler to onBeforeUnload, and by passing a string to a property of the event, the user will see a dialog asking him whether he wants to continue with the "unloading" (either closing the window or navigating away). Safari and Chrome don't support onBeforeUnload, and onUnload seems to be too late. Is there some way to replicate the same functionality in Safari/Chrome? NOTE: I'm not trying to keep the user hostage. I know this is nagging and un-cool. In fact, my site goes to great lengths to let the user go freely, and have everything in its place when they

cross-browser Onunload and Onbeforeunload ? (particularly opera 11)

一笑奈何 提交于 2019-11-26 22:02:42
问题 I have a form and I must notice user with alert() on exiting page while there are data in the form that had not been send. I've read that opera has a lot of problems with this. Opera 11 that is, because I need take into account only last version. So again, the alert should display on refresh, closing a tab, or closing whole browser. It would be nice to set event directly to the <form> element that would be launched on anything that leads to destroying this element. 回答1: Opera does not yet