onbeforeunload

jQuery bind beforeunload - not working with IE 9

时间秒杀一切 提交于 2020-01-05 07:56:58
问题 I have a piece of code i want fired when the page closes (basically, send a 'disconnected' message to the server. The execution should be fast enough for me not to have to cancel and restart the event. Further to that, it works perfectly in Chrome, Firefox and Safari, but not in IE9 on closing the tab. If i navigate to another page in IE9, my event fires. If i close the tab, it doesn't. I tried the following to bind my code: jQuery(window).bind("beforeunload", function() { DoSomeWork(); }); i

window.onbeforeunload performing query

感情迁移 提交于 2020-01-03 20:33:30
问题 I'm trying to perform a post query when the user leaves the page. The code I'm working with is <script type="text/javascript"> window.onbeforeunload = function(){ var used = $('#identifier').val(); $.post('conversation.php?leave=true',{ud:used}); } </script> Is there anything wrong with what I'm doing here? The result I get in the FF error console is just saying that other non-related functions/variables are not defined (since they are unloading). Any tips or pointers for what I need to fix?

window.onbeforeunload performing query

自闭症网瘾萝莉.ら 提交于 2020-01-03 20:33:06
问题 I'm trying to perform a post query when the user leaves the page. The code I'm working with is <script type="text/javascript"> window.onbeforeunload = function(){ var used = $('#identifier').val(); $.post('conversation.php?leave=true',{ud:used}); } </script> Is there anything wrong with what I'm doing here? The result I get in the FF error console is just saying that other non-related functions/variables are not defined (since they are unloading). Any tips or pointers for what I need to fix?

IE9 firing onbeforeunload event when the window opens

岁酱吖の 提交于 2020-01-03 03:29:24
问题 I'm building a site using the JFileUpload applet and want to handle the closing of a page in a certain way. JSTransferCancelled is called when the applet is cancelled. The following code is what I'm using to handle these events and it works in all browsers except IE. function JSTransferCancelled(){ bCancel=false; $.post("cancel.php"); self.close(); } $(window).load(function(){ $(window).bind('beforeunload',function(){ document.uploader.setEnabled(false); if(bCancel){ document.uploader.cancel(

prevent onbeforeunload to close page in any case

醉酒当歌 提交于 2019-12-30 09:09:08
问题 I want to prevent browser to close page in any case or in other case, Prevent browser to do anything when onbeforeunload is called. Here is my code which i have tried. (function() { var proxied = window.onbeforeunload; window.onbeforeunload = function(e) { e.preventDefault(); e.stopPropagation(); //i want to stop everything console.log('stay here'); // return 'message'; }; })(); I want to perform a action before leaving the page (disconnect the chat) 回答1: You can't outright prevent a user

suppress confirmation dialog while using onbeforeunload

主宰稳场 提交于 2019-12-30 09:04:29
问题 I am using onbeforeunload event to send ajax request to perform some clean up task. When I am using onbeforeunload, it shows the confirmation dialog on closing the tab. What I want is not to show any confirmation dialog and just send the clean up request. Following is the script I am using. window.onbeforeunload = unloadFunction; function unloadFunction() { var test_id = $('#test_id').val(); jQuery.ajax({ url: "/test/cleanup/" + test_id, cache: false }).done(function () { return false; });

window.onbeforeunload may fire multiple times

别说谁变了你拦得住时间么 提交于 2019-12-30 08:18:06
问题 Just because you don't see use for a feature doesn't mean it isn't useful. The Stack Exchange network, GMail, Grooveshark, Yahoo! Mail, and Hotmail use the onbeforeunload prompt to prevent/warn users that they are leaving a page after they have begun editing something. Oh yah, nearly every single desktop program that accepts saveable user-input data utilizes this prompt-user-before-leaving UX pattern. I have a function which behaves similarly to this one: window.onbeforeunload = function(){ /

Use JQuery or onbeforeunload for IE and FF

妖精的绣舞 提交于 2019-12-30 08:04:07
问题 I'm working in a Flex4 application, using javascript, in the "index.template.html" document. I'm having an issue being able to use onbeforeunload with Firefox. The application works perfectly in IE, but the exact same one doesn't sit well with FF. (See below) <script type="text/javascript"> window.onbeforeunload=before; window.onunload=after; function before(evt) { var flex=document.$(application)||window.$(application); flex.unloadMethod(); //custom method to log out the user } function

Using onbeforeunload without dialog?

本秂侑毒 提交于 2019-12-29 05:04:16
问题 I'm trying to post data when a user leaves my page. I have finally managed to find a working solution, however, it shows a confirmation dialog when the user leaves. I have tried return null; but it didn't work. Is it possible to disable the dialog? window.onbeforeunload = function() { $.post("track.php", { async: false, refid: refid, country: country, type: type, }); return ''; } 回答1: From the Mozilla Developer Network page: When this event returns a non-void value, the user is prompted to

How to make a cross-browser on-window-unload request?

白昼怎懂夜的黑 提交于 2019-12-28 16:14:34
问题 I have a Flash game that I'm trying to save the state of when the user closes the browser tab. It is using the following jquery code: //Called from Flash when window closes function sendRequest(url, params) { $.ajax({ type: "POST", async: false, url: url, data: params }) } $(window).unload(function() { //Make Flash attempt to save the game when the window closes. //Flash gets the necessary data and calls sendRequest() document["flashGame"].saveBeforeUnload(); }); Firefox: Works correctly