What are different ways to change url in javascript?

1) window.location.href = “http://www.yahoo.com/home.html”;
// document.URL is alternative to window.location.href

2) window.location.assign(“http://www.yahoo.com/home.html”);
// this will not alter the browser’s history.

3) window.location.replace(“http://www.yahoo.com/home.html”);
// this will alter the browser’s history

4) window.location.reload(true);
// force to get page from server

5) window.location.reload(false);
// get page from cache if available

Leave a Reply