javascript在条件后加载文件

javascript在条件后加载文件,javascript,Javascript,当我使用window.open(“文件”)时,它会将文件作为一个新选项卡打开。我已经尝试了.load,但它也不起作用。您可能知道如何解决我的问题,即html文件直接在运行窗口中加载 function progress() { var prg = document.getElementById('progress'); var percent = document.getElementById('percentCount'); var counter = 5; var pr

当我使用
window.open(“文件”)
时,它会将文件作为一个新选项卡打开。我已经尝试了
.load
,但它也不起作用。您可能知道如何解决我的问题,即html文件直接在运行窗口中加载

function progress() {
   var prg = document.getElementById('progress');
   var percent = document.getElementById('percentCount');
   var counter = 5;
   var progress = 25;
   var id = setInterval(frame, 64);

   function frame() {
      if (counter == 100) {
          clearInterval(id);
          window.open("welcome.html")
      } 
      else {
          progress += 5;
          counter += 1;
          prg.style.width = progress + 'px';
          percent.innerHTML = counter + '%';
      }
   }
}

progress();

您可以在当前选项卡中打开文件,但要将
\u self
参数添加到
名称
参数:

window.open("welcome.html","_self");
                              ▲
您也可以通过使用
window.location.href
实现同样的效果:

window.location.href = "welcome.html";

您可以在当前选项卡中打开文件,但要将
\u self
参数添加到
名称
参数:

window.open("welcome.html","_self");
                              ▲
您也可以通过使用
window.location.href
实现同样的效果:

window.location.href = "welcome.html";
你可以用

window.location.href = "welcome.html";
它将在同一选项卡中打开文件。

您可以使用

window.location.href = "welcome.html";

它将在同一选项卡中打开文件。

您可以使用
window.location.assign(“welcome.html”)
而不是
window.open(“welcome.html”)


看到这个

你可以使用
window.location.assign(“welcome.html”)
而不是
window.open(“welcome.html”)

请参见此

的可能重复