Home / Snippets / URL Redirect One-Liner Snippet
URL Redirect One-Liner Snippet cover

URL Redirect One-Liner Snippet

222

2 years ago

0 comments

To redirect a user to a specific URL / Location you can make use of the "location.href " object and it will automatically redirect the page
const urlRedirect = url => location.href = url;
Now you can use the function below anywhere on your web page.
urlRedirect("https://postsrc.com"); // it will automatically navigate to the URL
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this