Sebastian Schmidt
Sebastian Schmidt

Reputation: 3

javascript loading a file after a condition

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();

Upvotes: 0

Views: 58

Answers (3)

Koby Douek
Koby Douek

Reputation: 16675

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";

Upvotes: 1

Ram Segev
Ram Segev

Reputation: 2571

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

See this article

Upvotes: 0

Pratik Gadoya
Pratik Gadoya

Reputation: 1511

you can use

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

It will open file in same tab.

Upvotes: 1

Related Questions