check if onunload is available before binding