需要window.location.href行为说明

时间:2019-06-27 17:47:05

标签: javascript

我注意到,当您不将window.location.href绑定到某个事件浏览器时,不会让我返回页面。请解释为什么会这样


   let link = document.getElementById('link');

   link.addEventListener('click',function(){
    window.location.href = "v.html"
   })

// the code above works just fine and i can go back in history afterwards
// I can't do the same with the code below

   if(1){
      window.location.href = "v.html"
   }

0 个答案:

没有答案