0

When I use window.open("file") then it'll open the file as a new tab. I already tried .load but it doesn't work either. You may know how to solve my problem that the html file loads directly in the running window ?

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();
Koby Douek
  • 16,156
  • 19
  • 74
  • 103
  • 2
    Possible duplicate of [Open URL in same window and in same tab](https://stackoverflow.com/questions/8454510/open-url-in-same-window-and-in-same-tab) – Durga Nov 29 '17 at 07:57

3 Answers3

1

You can open the file in the current tab but adding the _self argument to the name parameter:

window.open("welcome.html","_self");
                              ▲

You can also achieve the same by using window.location.href:

window.location.href = "welcome.html";
Koby Douek
  • 16,156
  • 19
  • 74
  • 103
1

you can use

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

It will open file in same tab.

Pratik Gadoya
  • 1,420
  • 1
  • 16
  • 27
0

You can use window.location.assign("welcome.html"); instead of window.open("welcome.html");

See this article

Ram Segev
  • 2,563
  • 2
  • 12
  • 24