Skip to main content

Archive

Show more

How to redirect to another page using javascript

how-to-redirect-to-another-page-using-javascript


Question: how to redirect to another page using javascript

Answer:

There are several methods available to redirect to a new page in JavaScript, some of which we will look at in this article. So let's get started without further ado.


First: using 'href'.

window.location.href = "https://www.rustcodeweb.com";


Second: using 'replace()'.

window.location.replace("https://www.rustcodeweb.com");


Third: using 'window.location'.

window.location = "https://www.rustcodeweb.com";


Four: using 'window.location.assign()'.

window.location.assign("https://www.rustcodeweb.com");


Five: using 'self.location'.

self.location = "https://www.rustcodeweb.com";


Six: using 'top.location'.

top.location = "https://www.rustcodeweb.com";


Six: using 'window.open()'.

window.open('https://www.rustcodeweb.com');


We try to provide you the best content, if there is any mistake in this article or there is any mistake in code, then let us know.

Comments