Change event handler syntax for beforeunload

Apparently this is the only syntax that will reliably show the warning
message.