JS Coding Questions Logo
JS Coding Questions
#120💼 Interview💻 Code

How do you redirect new page in javascript

Advertisement

728x90

In vanilla javascript, you can redirect to a new page using the location property of window object. The syntax would be as follows,

javascript
1function redirect() {
2  window.location.href = "newPage.html";
3  }

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 36

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
120of476