onunload

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

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 t...

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

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 f...

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

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 ...

Jquery Effect Onunload

I would like to use the jquery slideUp effect when the user navigates away from the page just to make the page look cool as it closes. I assume that I should use the onunload event but how can I delay the page closing long enough for the effect to run to completion. One of the options that came to mind is effectively hijacking the page...

JavaScript + onunload event

I want to fire onunload event to do some clean up operations, I have multiple tabs(Navbar) showing multiple links to different web pages,my problem is that even when I'm in some other page my unload function which is in tag of some other jsp is fired. Please help to resove this, I want unload function to be called when user closes brow...

Opera: Detecting back, forward, refresh and close events ...

I'm currently working on a jQuery plugin that tracks a visitors mouse behavior. Movements, clicks, scrolling and resizing are all recorded and sent, via Ajax, to a location where this data is parsed and stored. Originally, the data is sent to a script when the user leaves the page. By 'leaves' I'm referring to refreshing, going back and...

Alternative for JavaScript onUnload

Hi, there is an alternative to the Javascript onUnload? I use JSP Jakarta Struts framework with a Servlets. I must know, when is window closing, because not everyone clicks on Logout button. How do you handle it in your applications? ...

Strategies for preserving form data ( on tab/browser close )

I have an issue with a task management application where occasionally users close their browsers/tabs and the information which they type goes away because they accidentally close a browser/tab, resulting in the loss of the text which they've entered ( and some can spend half an hour entering in text ). So I have to provide a solution, ...

DOM Window unload event, is it reliable?

Can I rely on the window unload event to be triggered when a user closes a tab/window/browser? Edit: Found a list of what triggers the unload event in IE. http://msdn.microsoft.com/en-us/library/ms536973%28VS.85%29.aspx I would like to know in which edge cases the unload event won't be triggered. ...

AJAX - when user leaves page - good or bad practice/implementation?

I was just reading http://stackoverflow.com/questions/1619930/how-to-check-users-leave-a-page earlier on when suddenly I thought of performing AJAX when user leaves the page to send analytical data back to the server. Is performing AJAX on the onunload event a good or bad practice/implementation? ...

How can i get the destination url in javascript onbeforeunload event?

I've searched for hours, but I couldn't find a solution for this. window.onbeforeunload = warn; This doesn't work: function warn (e) { var destination = e.href; alert(destination ); } Okay, so to clear the things. If the user clicks on a link on the page itself, it is easy, because you can add an eventhandler to all of the ...

window.onload/onunload and <body onload/onunload >

I have read the thread window.onload vs <body onload=""/>. In that thread, many claim that window.onload and body onload="" are identical. This is not what I experience. Consider the two test pages: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="...

Report the time spent on a page to the server.

Is it possible to report the time spend on a page back to server when the visitor leaves the page by closing the tab or the browser? Using Javascript. And it will work on Firefox, Google Chrome, Safari, Opera, and IE8 (IE7 and 6 are not important). But it will work in any case; even while the browser is closing, or it is typed another ...

Javascript/jQuery: does anybody already created a loading fixed div on top 100%:100% of the page with jquery?

Hi all, i used sometimes a 'loading' method with the javascript onload & onunloadbody events.(www.restaurantebarocortico.com) Now i'm learning jQuery, and i used the $(document).ready & $(window).unload to replace the old events, but the unload event isn't working correctly. Does anybody knows another method to call a function on unloa...

JavaScript onunload only called if document fully loaded?

Hi, I haven't seen any mention of this is David Flanagan's "JavaScript - the Definitive Guide" book (I've asked this question on O'Reilly Answers too), or anywhere else for that matter, but I am finding that window.onunload is not invoked unless the document fully loaded, which is quite annoying! That's true for IE8 and Chrome 3 at leas...

Javascript onunload form submit isn't submitting data

I currently have form that checks if a user has unsubmitted changes when they leave the page with a function called through the onunload event. Here's the function: function saveOnExit() { var answer = confirm("You are about to leave the page. All unsaved work will be lost. Would you like to save now?"); if (answer) { doc...

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

Hi, 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. ...

How can I get reason of page unloading in javascript's onunload event, in IE?

There may be different reasons of page unloading: 1 User closes the current window. 2 User navigates to another location. 3 Clicks the Back, Forward, Refresh, or Home button. 4 User submits a form, and then browser starts to unload current page and load page with results of form submitting. (Assuming that the current window is the fo...

Is it possible for onunload confirm to open a new url in the same window?

Hi - this is my first post and I'm a JS novice, so please forgive my ignorance... Heres my question, its in two parts: 1.) At onunload I want an alert that asks the user if they would like to go to a related URL. The code I'm using works, but it open the URL in a new window and this can be blocked by a pop-up blocker even though the us...

Is there a recommended approach to handle saving data in response to within-site navigation without onunload event?

Hello all, Preamble to scope my question: I have a web app (or site, this is an internal LAN site) that uses jQuery and AJAX extensively to dynamically load the content section of the UI in the browser. A user navigates the app using a navigation menu. Clicking an item in the navigation menu makes an AJAX call to php, and php then retu...