html5 replaceState

var bb="history.state = "+(JSON.stringify(history.state))+" , \n\nlocation: " + document.location;
	console.dir("bb : "+bb);
	
	window.addEventListener("popstate", function(e){
		var currentState = e.state;
		var bb="history="+(JSON.stringify(history))+" , \n\n location: " + document.location;
		console.dir("bb : "+bb);
		alert(bb);
	}, false);
	
	function replaceState(){
		var data={aa:"122"};
		var url=location.pathname;
		window.history.replaceState(data,document.title,url+"#!/stealingyourhistory");
		//history.replaceState(null, document.title, location.pathname+"#!/stealingyourhistory");  
		//history.replaceState({page: 1}, "title 1", "?page=1");
		console.dir(history);
		console.dir("pathname : "+location.pathname);
	}

相关推荐