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

What is 'this.' keyword in JavaScript

Introduction to webshare API (navigator.share)