why do you need a typeof here? can't you just use if (window.onhashchange !== undefined) ?