fixes #201.

fixes #201. added unbeforeunload event handler that checks for dirty state.