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!