Skip to content

Instantly share code, notes, and snippets.

@saikat
Created November 20, 2009 02:30
Show Gist options
  • Save saikat/239237 to your computer and use it in GitHub Desktop.
Save saikat/239237 to your computer and use it in GitHub Desktop.
- (void)setDocument:(CPDocument)aDocument
{
if (aDocument === _document)
return;
[super setDocument:aDocument];
var unloadFunction = function() {
if ([_document isDocumentEdited]) {
return "Your document has unsaved changes. If you leave, you will lose any unsaved changes to your document.";
}
};
if (document.attachEvent)
[[self window] platformWindow]._DOMWindow.attachEvent("onbeforeunload", unloadFunction);
else
[[self window] platformWindow]._DOMWindow.onbeforeunload = unloadFunction;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment