Fixed a problem with onbeforeunload