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

JavaScript introduction to variables

Solutions to blocked URLs on Facebook

How to stop moz dotbot from accessing your website

How to set content disposition headers for express nodejs apps

How to set content disposition header for nginx server to force content download