onunload

I need to capture the window.onbeforeunload event

无人久伴 提交于 2021-01-01 18:37:01
问题 I am working on a project where I need to capture the browser close event ( unload or beforeunload ). For that I have tried the code below but it's not working. The code is working only if I open the browser console window (maybe just for a second) but it is required otherwise it's not working. Example $(window).on('beforeunload', function(e) { $.ajax({ type: "POST", url: "url", data : {'value' : 1}, dataType:'json' }); return false; }); 回答1: The beacon API is meant specifically for that.

I need to capture the window.onbeforeunload event

帅比萌擦擦* 提交于 2021-01-01 18:36:13
问题 I am working on a project where I need to capture the browser close event ( unload or beforeunload ). For that I have tried the code below but it's not working. The code is working only if I open the browser console window (maybe just for a second) but it is required otherwise it's not working. Example $(window).on('beforeunload', function(e) { $.ajax({ type: "POST", url: "url", data : {'value' : 1}, dataType:'json' }); return false; }); 回答1: The beacon API is meant specifically for that.

How to logout during onbeforeunload/onunload using Javascript

China☆狼群 提交于 2020-04-28 19:57:51
问题 <script type="text/javascript"> window.onbeforeunload=before; window.onunload=after; function before(evt) { var message="If you continue, your session will be logged out!"; if(typeof evt=="undefined"){ evt=window.event; } if(evt){ evt.returnValue=message; } } function after() { var flex=document.${application}||window.${application}; flex.unloadMethod(); //calls the flex class containing the "unloadMethod()" which //calls the logout.jsp that does the actually dropping of credentials } <

Win8.1 will fire unload and load event to the WPF application when we close and reconnect to this machine using RDC from win7 or other OS

送分小仙女□ 提交于 2020-04-07 18:44:32
问题 This is a strange issue only in Win8.1. As we all know, if there is a running application in a machine, there should not be any other behavior against the application when we connect/disconnect/reconnect to this machine by Remote Desktop Connection. However, we found that Win8.1 will fire unload and load events to the WPF application when we close and reconnect to the machine using RDC. And this is an unwanted behavior which may cause error. Here are the stable reproduce steps: Write a WPF

Removing event listeners before leaving a page

岁酱吖の 提交于 2020-02-25 09:37:54
问题 I've developed a javascript drag and drop that mostly uses the standard 'allowdrop', 'drag' and 'drop' events. I wanted to customise the 'ghosted' dragged object, so I've added a display:none div that get populated with the innerHTML of the draggable element and made visible (display:block;) when the user starts dragging. The draggable div is absolutely positioned and matches the mouse movements. For this I needed to add 3 event listeners to document.body. They are as follows: document.body

call a4j:commandButton from javascript on window unload

别等时光非礼了梦想. 提交于 2019-12-31 04:28:05
问题 I am not able to call a4j:commandButton click on window unload. my jsf code is here 1st the javascript in which i have window unload method and i have called button click in that function. <script type="text/javascript"> window.onbeforeunload = function() { document.getElementById('pForm:closeTime').click(); } </script> 2nd i have hidden a4j:commandButton in body <h:form id="pForm"> <a4j:commandButton id="closeTime" value="" action="#{controller.update}" oncomplete="javascript:window.close()"

C# WebPages : manage Exit events or quit with no user action server side

最后都变了- 提交于 2019-12-24 19:07:13
问题 What is the better solution to manage Exit or Quit events when user exit to other pages with no action?. This event need to be raised only one time and be usefull to delete all temporary files or datas not stored after the abandon of this page. Is a perfect to use as cleaning method server side. Thanks. 回答1: The web is stateless so there shouldn't really be anything to clean up. However, sometimes you may want to kill the session when the user tries to close browser. I guess you could catch

onbeforeunload and onunload getting one to work after the other

喜你入骨 提交于 2019-12-24 14:10:53
问题 I am having some trouble with the on before unload and the unload method. I thought i set the code right in terms of the onload method only firing up after the confirm method for onbeforeunload was set a true. but sadly that isn't the case, what is happening is the unload method is starting even if the onbeforeunload method is set to false and the person wants to stay at the website. Here is the code I am working on it has changed a lot since I started hope its okay. I am sure it isn't since

Javascript: Check if the user is navigating away with a form submit or a simple link click

試著忘記壹切 提交于 2019-12-24 04:53:35
问题 I need to do remind the users something when they are leaving the page, and that can be handled with the window.onUnload event. But I also need to check if the user is navigating away by submitting the form on the page, or by clicking the navigation links. I could use the form's onSubmit event to set a flag, and then check against that flag in the window.onUnload event, but I am not sure which one fires first. any ideas ? 回答1: You actually want window.onbeforeunload window.onbeforeunload =

Is there a way using ASP.NET to always run some server side code when a user leaves a page?

流过昼夜 提交于 2019-12-24 03:10:55
问题 I was wondering if there is any way to always run some server side code when a user leaves a page in ASP.NET. The page Unload event is no good because that doesn't get called if someone clicks on a link. Ideally I'd also like the code to run even if the user closes the browser. I suspect what I'm asking isn't possible, but it doesn't hurt to ask 回答1: Problem is, HTTP is a stateless protocol, so when the page has finished being served, you wont know if the user is still on the page or not. The