Change event handler syntax for beforeunload

Apparently this is the only syntax that will reliably show the warning
message.
Merge pull request #288 from stianjensen/show-unsaved-changes-warning

Change event handler syntax for beforeunload