onbeforeunload

user-unfriendly onbeforeunload / onunload

倾然丶 夕夏残阳落幕 提交于 2019-12-06 22:56:27
I'm struggling with onbeforeunload, onunload and generating the right messages at the right time. Any idea welcome. This is the situation: when I use onbeforeunload, the user gets a message to choose whether to navigate away, but I can't turn it off - the message is standard and appears regardless what's in the event handler. when I use onunload, I can control the "bye" messages that occur, but I cant offer the user the opportunity to change their mind. So for example, if there is data to save. With onbeforeunload, a message pops up, -regardless of the state of the user's data- asking if they

Multiple onbeforeunload() and onunload() events

冷暖自知 提交于 2019-12-06 03:07:10
问题 I have a strange issue from a client in that our code, which they include uses onbeforeunload() to trigger a dialog, but they are also including another companies code which also binds this event handler. Is it possible for both to execute at the same time? I've been reading this, http://oreilly.com/catalog/9780596101992 "JavaScript: The Definitive Guide, Fifth Edition" to try and help better understand what is happening in the browsers internals and the javascript stack, but it's proving

Why jQuery sometimes overwrites window.onbeforeunload?

大憨熊 提交于 2019-12-05 23:52:10
问题 I am having strange problem with jQuery (1.6.x). I have this simple call on my page: window.onbeforeunload = function() { return 'Are you sure ?'; }; But it doesn't work, because as I've found out, jQuery overwrites content of the window.onbeforeunload. In JS console, I can see that window.onbeforeunload contains piece of jQuery code: function( e ) { // Discard the second event of a jQuery.event.trigger() and // when an event is called after a page has unloaded return typeof jQuery !==

Running server-side function as browser closes

女生的网名这么多〃 提交于 2019-12-05 05:28:25
Background: I'm creating a very simple chatroom-like ASP.NET page with C# Code-Behind. The current users/chat messages are displayed in Controls located within an AJAX Update Panel, and using a Timer - they pull information from a DB every few seconds. I'm trying to find a simple way to handle setting a User's status to "Offline" when they exit their browser as opposed to hitting the "Logoff" button. The "Offline" status is currently just a 1 char (y/n) for IsOnline. So far I have looked into window.onbeforeunload with Javascript, setting a hidden form variable with a function on this event ->

prevent OnBeforeUnload() event from happening in refresh/F5

白昼怎懂夜的黑 提交于 2019-12-05 00:09:33
问题 I'm using onbeforeunload event to perform operations during the closing page. I do not want the event to happen in the case of Refresh / F5 . Is there a way or other event to do this? 回答1: Unfortunately onbeforeunload event listens the page state in the browser. Going to another page as well as refreshing will change the page state, meaning onbeforeunload will be triggered anyway. So I think it is not possible to catch only refresh. But, if you'll listen and prevent Keypress via JavaScript,

WebBrowser Control prevent Next Url navigated

限于喜欢 提交于 2019-12-04 22:32:20
I wonder if there is a anyway to remove the WebBrowser Message are you sure you want to navigate away from this page When I try to navigate another url, it happens. I tried this methods e.Cancel = False WebBrowser1.Dispose() WebBrowser1 = New WebBrowser WebBrowser1.ScriptErrorsSuppressed = True WebBrowser1.Navigate(New Uri("https://www.google.com")) That is coded into the website, so you'd have to inject some Javascript into the page to override the prompt. Be careful with this, though. This requires overriding the entire window.onbeforeunload event handler , and some pages might have decided

Autosave with “unload” event and ajax call on logout : order of actions is causing an issue

心不动则不痛 提交于 2019-12-04 20:13:47
问题 I'm using a AutoSave feature on an online editor. When an user leaves the page (detected with unload or beforeunload event), I'm sending a AJAX request (async = false) to save the data. I have a problem in Firefox et sometimes in Chrome because that serie of events is happening : event fired request send the page change and the user is disconnected request analysed by the server => problem ! request response received by browser Of course since the user has been disconnected the "save" request

Unexpected performace.navigation.type onbeforeunload

为君一笑 提交于 2019-12-04 17:48:59
I'm trying to handle some logic on before unload and I don't want that logic to run if the user is reloading the page or going back. I've set up something like this. window.onbeforeunload = function(e) { if(window.event && window.event.clientX){ //IE //some logic } else if (e.currentTarget.performance.navigation.type === e.currentTarget.performance.navigation.TYPE_RELOAD) { // another logic } else if(e.currentTarget.performance.navigation.type === e.currentTarget.performance.navigation.TYPE_BACK_FORWARD){ // yet another logic } } I have other code to handle refresh and such from keyboard input

Google chrome onbeforeunload wrong behavior with iframe

安稳与你 提交于 2019-12-04 17:16:40
问题 Let say I have two pages. One of them contains another one inside as iframe. If you subscribe to onbeforeunload event on the parent page, then this event doesn't triggers if you close tab when iframe is in focus. I suppose it is a bug as written here: Google Chrome issues But I mentioned that, for example, google docs handle this situation. Can anyone give me a solution? Important note that I have no actual access to the iframe content as it is a third party html editor (WYSIWYG). 回答1: I know

How can I prevent window.onbeforeunload from being triggered by javascript: href links in IE?

浪尽此生 提交于 2019-12-04 07:46:13
问题 I'm building a fail safe for my form that is going to warn users that if they leave the page their form data will be lost (similar to what gmail does). window.onbeforeunload = function () { if (formIsDirty) { return "You have unsaved data on this form. Don't leave!"; } } The above function works great in firefox, but in IE it is triggered by any href link, even ones that are links to javascript and not other pages. for example.... <a href='javascript:someFunction();'>click</a> I'm wondering