Opened 13 years ago

Closed 13 years ago

#7771 closed enhancement (duplicate)

propagate return values from functions set in dojo.addOnUnload

Reported by: lipik Owned by: sjmiles
Priority: high Milestone: tbd
Component: Events Version: 1.2beta
Keywords: functionality, limitation, onbeforeunload Cc: James Burke
Blocked By: Blocking:


onbeforeunload allows the application to request that user reconsider navigating away from the page, in case there is some unsaved data. This is done by returning a string from the event handler, which is displayed in a browser-generated confirmation box.

However, dojo.addOnUnload does not return anything, so this functionality is lost. Alternatively, _handleNodeEvent in hostenv_browser.js can be rewritten to call the new handler after the old one, and only if the old handler did not return a string...

Change History (4)

comment:1 Changed 13 years ago by dante

Cc: James Burke added
Priority: highnormal
Type: defectenhancement

comment:2 Changed 13 years ago by lipik


I see that that you marked this as enhancement. I would like to point out that in the present form, I cannot use dojo.addonUnload() at all if I require confirmation on exit, so it seems to me to be a defect in the toolkit. The fix is pretty simple (hostenv_browser.js, line 325 in RC2 source):

var _handleNodeEvent = function(/*String*/evtName, /*Function*/fp, /*optional*/returnResult){

var oldHandler = _w[evtName]; _w[evtName] = function(){

var s = fp.apply(_w, arguments);

return (returnResult && typeof(s) == "string" && s)
(oldHandler && oldHandler.apply(_w, arguments));



and line358:

_handleNodeEvent("onbeforeunload", function() { dojo.unloaded(); }, true);

comment:3 Changed 13 years ago by lipik

oops, html formatting ate the OR condition in the return statement

comment:4 Changed 13 years ago by James Burke

Resolution: duplicate
Status: newclosed

Closing this in favor of the existing ticket on this issue: #6411, but I will reference this ticket in that other ticket.

Note: See TracTickets for help on using tickets.