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 Snake Game using JavaScript and html5

How to get user's ip address in JavaScript

Adding Gameover and introduction screen on HTML Canvas

JavaScript intro to classes

How to use canvas context rect method for drawing rectangles