Polyfill hashchange Event oldURL and newURL attributes for IE 9+

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}
			});
		});
	}
}());


你可能感兴趣的:(hashchange,oldURL,HashChangeEvent,newURL)