Add the following code before your code, then it will prepare oldURL and newURL for you.
(function(){
if(!window.HashChangeEvent){
var lastURL=document.URL;
window.addEventListener("hashchange",function(e){
var oldURL=lastURL;
var newURL=document.URL;
lastURL=newURL;
Object.defineProperties(e,{
oldURL:{enumerable:true,configurable:true,value:oldURL},
newURL:{enumerable:true,configurable:true,value:newURL}
});
});
}
}());