Redirecting a webpage in JavaScript

Redirects are way of navigating a user to another webpage or location

redirects are normally done by server side implementations.

it's possible to do redirects using JavaScript too

window.location is a object that stores current location information such as path, port, hostname and href or the location in the address bar of your browser changing it invokes a redirect it's a simple way to redirect a user to another webpage

Syntax
window.location.asign('https://example.com')

or simply like

window.location = "https://example.com"

or simply omit window

location = "https://example.com"

Comments

Popular posts from this blog

How to make a html5 breakout game in JavaScript

How to tabulate array key values using console.table

How to set content disposition headers for express nodejs apps

Ways of iterating Object properties in JavaScript

How to evaluate a string on a regular expression rule in JavaScript