Javascript Redirect Page

Aug 20, 2018
window.location.href
// full urlwindow.location.href = "https://www.google.com"// relative urlwindow.location.href = "/about"// this works as wellwindow.location = "https://www.google.com"

If you are using jQuery

$(location).attr('href', url);

Alternatively you can also use

// replace current history, not possible to go backwindow.location.replace(url);// keep history, can click backwindow.location.assign(url);

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.