Questions tagged [onunload]

198 questions
72
votes
3 answers

How can I get the destination URL for the 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…
misnyo
  • 1,707
  • 3
  • 16
  • 17
38
votes
7 answers

window.onunload is not working properly in Chrome browser. Can any one help me?

I have written this code function winUnload() { alert("Unload Window"); MyMethod(); } window.onunload = function() { winUnload(); } This code is working fine in IE and Firefox. But this code is not working in Chrome. Both the…
Imran
  • 389
  • 1
  • 3
  • 4
28
votes
6 answers

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

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…
Maxx
  • 3,925
  • 8
  • 33
  • 38
19
votes
7 answers

How to block pop-up coming from iframe?

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?
Paul
  • 1,928
  • 8
  • 24
  • 32
18
votes
2 answers

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…
bhseo
  • 276
  • 1
  • 2
  • 7
17
votes
3 answers

Capturing result of window.onbeforeunload confirmation dialog

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…
xzyfer
  • 13,937
  • 5
  • 35
  • 46
16
votes
1 answer

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

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.…
capcom923
  • 638
  • 5
  • 15
11
votes
0 answers

Is the onbeforeunload event not supported on iPhone?

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() { …
Dan Tao
  • 125,917
  • 54
  • 300
  • 447
10
votes
1 answer

Are JavaScript event listeners cleaned up automatically?

After an element is removed from the DOM, will its event listeners automatically be unregistered and their referenced resources (closures) cleaned up? If yes, will the answer change if some non-event listener code holds a reference to the…
ecraig12345
  • 2,328
  • 1
  • 19
  • 26
9
votes
3 answers

OnUnload message needed for external links

I need a message script that will only come up when people are leaving the current webpage and not the current website. When people are leaving the website entirely, the message will come up and they will need to press the OK button to stay at the…
tumtummetjes
  • 91
  • 1
  • 1
  • 2
8
votes
4 answers

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…
Saravanan M
  • 4,697
  • 5
  • 35
  • 37
8
votes
1 answer

What is the most unobtrusive way to implement a custom 'beforeunload' dialog?

I'm talking about a styled dialog, instead of the default 'beforeunload' dialog that can't be styled. See Facebook: What is the most unobtrusive way to make this? Preferrable some script that I declare once, and magically always works. I'm think…
Dirk Boer
  • 8,522
  • 13
  • 63
  • 111
7
votes
6 answers

Javascript onload and onunload

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.
George
  • 2,050
  • 6
  • 26
  • 36
7
votes
2 answers

Closing Chrome window not sending data with sendBeacon in unload event handler

I am trying to send data when the window closes to prevent 2 people from editing and overwriting each others data. Currently I am using a sendBeacon within a unload event handler. FireFox: Refresh: Works Back button: Works Close window:…
webdevtrev
  • 79
  • 1
  • 3
7
votes
4 answers

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

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…
rsk82
  • 28,217
  • 50
  • 150
  • 240
1
2 3
13 14