]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/unload.js.uncompressed.js
1 define("dojo/_base/unload", ["./kernel", "./connect"], function(dojo
, connect
) {
5 // This module contains the document and window unload detection API.
10 dojo.windowUnloaded = function(){
12 // signal fired by impending window destruction. You may use
13 // dojo.addOnWindowUnload() to register a listener for this
14 // event. NOTE: if you wish to dojo.connect() to this method
15 // to perform page/application cleanup, be aware that this
16 // event WILL NOT fire if no handler has been registered with
17 // dojo.addOnWindowUnload. This behavior started in Dojo 1.3.
18 // Previous versions always triggered dojo.windowUnloaded. See
19 // dojo.addOnWindowUnload for more info.
23 dojo
.addOnWindowUnload = function(/*Object?|Function?*/obj
, /*String|Function?*/functionName
){
25 // registers a function to be triggered when window.onunload
28 // The first time that addOnWindowUnload is called Dojo
29 // will register a page listener to trigger your unload
30 // handler with. Note that registering these handlers may
31 // destory "fastback" page caching in browsers that support
32 // it. Be careful trying to modify the DOM or access
33 // JavaScript properties during this phase of page unloading:
34 // they may not always be available. Consider
35 // dojo.addOnUnload() if you need to modify the DOM or do
36 // heavy JavaScript work since it fires at the eqivalent of
37 // the page's "onbeforeunload" event.
39 // | dojo.addOnWindowUnload(functionPointer)
40 // | dojo.addOnWindowUnload(object, "functionName");
41 // | dojo.addOnWindowUnload(object, function(){ /* ... */});
43 if (!dojo
.windowUnloaded
) {
44 connect
.connect(win
, "unload", (dojo
.windowUnloaded= function(){}));
46 connect
.connect(win
, "unload", obj
, functionName
);
49 dojo
.addOnUnload = function(/*Object?|Function?*/obj
, /*String|Function?*/functionName
){
51 // registers a function to be triggered when the page unloads.
53 // The first time that addOnUnload is called Dojo will
54 // register a page listener to trigger your unload handler
57 // In a browser enviroment, the functions will be triggered
58 // during the window.onbeforeunload event. Be careful of doing
59 // too much work in an unload handler. onbeforeunload can be
60 // triggered if a link to download a file is clicked, or if
61 // the link is a javascript: link. In these cases, the
62 // onbeforeunload event fires, but the document is not
63 // actually destroyed. So be careful about doing destructive
64 // operations in a dojo.addOnUnload callback.
66 // Further note that calling dojo.addOnUnload will prevent
67 // browsers from using a "fast back" cache to make page
68 // loading via back button instantaneous.
70 // | dojo.addOnUnload(functionPointer)
71 // | dojo.addOnUnload(object, "functionName")
72 // | dojo.addOnUnload(object, function(){ /* ... */});
74 connect
.connect(win
, "beforeunload", obj
, functionName
);
78 addOnWindowUnload
: dojo
.addOnWindowUnload
,
79 addOnUnload
: dojo
.addOnUnload