Redirecting to another page in javascript

I have window.location.href = "forwardedpage.html"; in my script.js page. It gives me an error saying not found. Any idea why this would not work. It is part of a function that is invoked when a button is clicked.

function buttonIsClicked(){
  //var secretName = "abdul"
  var inputName = document.getElementById("nameBox").value;
  //We are going to use a pop-up "alert" window to display the user's name...
  alert("Hello " + inputName + "! Redirecting to Google...");
  //everything before this point works. When it comes to the following, 
  //it comes up with an error saying not found.
  window.location.href = "forwardedpage.html"; // This forwards the user's browser to forwardedpage.html
}

Hey @asad3786, welcome to the forums!

I recommend doing this :

window.location.replace(YOUR_URL);

Thank you, hugoondev! Actually it worked for me after I changed the name of the html file. Is this not an issue with the ide?

1 Like

@asad3786, I don’t think so!

It will say not found if you don’t have a file named ‘forwardedpage.html’, because the program can’t find the file.
Similarly, if you rename index.html to something else, the program won’t run because one of the Replit files are made to run the program with index.html.