Javascript Chrome中的Popstate问题

Javascript Chrome中的Popstate问题,javascript,java,jquery,angularjs,spring,Javascript,Java,Jquery,Angularjs,Spring,Hi在单击“上一步”按钮时,有下面的代码来实现逻辑 window.addEventListener('popstate',function(){ var位置=document.location; if(history.state&&typeof history.state.selectedVariantColor!=“未定义”){ var url=window.location.href.split(“?”)[0]+history.state.selectedVariantColor; win

Hi在单击“上一步”按钮时,有下面的代码来实现逻辑

window.addEventListener('popstate',function(){
var位置=document.location;
if(history.state&&typeof history.state.selectedVariantColor!=“未定义”){
var url=window.location.href.split(“?”)[0]+history.state.selectedVariantColor;
window.location.replace(url);
} 
否则{
window.location.href=位置;
}
});