The window object in JavaScript has an event handler called onload . When this event handler is used, the entire page and all of its related files and components are loaded before the function listed in the onload event handler is executed, hence the term "on load."
Questions tagged [window.onunload]
77 questions
2
votes
1 answer
Handling unsaved state of objects in grails
I have a problem that probably is rather a design problem than a technical one.
Assuming I have these classes:
class A {
def someInfo
static hasMany = [b: B]
}
class B {
A a
def info
def moreInfo
...
def…

mwio
- 53
- 7
2
votes
2 answers
img requests before windows close
I have the situation that data needs to be reliably sent before browser window closes. My current implementation is to use a synchronous AJAX calls. However that's unlikely to work in the near future because the browsers are deprecating synchronous…

Shawn
- 32,509
- 17
- 45
- 74
2
votes
6 answers
Javascript window.onunload fires off after Page_Load
I have noticed that window.onunload event fires off AFTER page_load event which makes no sense.
This behaviour is creating an issue for me - in my unonload I clear the session, so if the Page_Load first BEFORE onunload, there are errors on the page…

sarsnake
- 26,667
- 58
- 180
- 286
2
votes
1 answer
Will an async ajax query complete if triggered by window.onbeforeunload?
I have tested this and it seems like even if the page unloads, the async action completes regardless if the tab is closed or if the tab navigates to a new url. The server it's calling to however is pretty snappy.
What is the process behind the…

dsp_099
- 5,801
- 17
- 72
- 128
2
votes
1 answer
Javascript OnPageUnload - on "leave page" must call additional method
This is the problem: my web application (php) has a wizard feature which gathers customer's data page by page, and stores it in session. If customer tries to navigate away from the page before they have completed the wizard, I would like to display…

Katya S
- 1,321
- 3
- 17
- 31
1
vote
1 answer
Async Event on Tab Close
I'm looking for a solid solution to carry out an asynchronous event on a tab close in JavaScript
For context, I have a site with multiple (thousands) of pages that should only allow one user to edit a page at a time (i.e. two users can't be writing…

mmarion
- 859
- 8
- 20
1
vote
1 answer
Javascript onclose event
How can I run javascript when user close the browser. I tried to use 'onunload', but it calls every time I press F5/refresh button?
Thanks

ihorko
- 6,855
- 25
- 77
- 116
1
vote
1 answer
$(window).unload gets triggered by many events, how can I trigger an event only when a tab is closed?
I want to clear the local storage when a tab is closed. If I use $(window).unload, it'll clear the storage also when the page is refreshed. Is there a way to do it only if a tab is closed?

brainoverflow
- 691
- 2
- 9
- 22
1
vote
1 answer
I need to capture the window.onbeforeunload event
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)…

Sunil Bamal
- 87
- 1
- 14
1
vote
1 answer
How do I get window onunload event trigger to work in Chrome v73.x?
It appears that with the latest release of Chrome (Version 73.0.3683.103 (Official Build) (64-bit)), window onunload event handler isn't being called.
In the latest version of Chrome, my onunload anonymous function seems unreachable.
I'm following…

Kyle Dalan
- 15
- 1
- 4
1
vote
1 answer
Open a Modal when closing browser tab
Want to open a modal when closing browser tab. Tried window.onbeforeunload , window.unload but not working. Any Other Solution with JavaScript or jQuery?