How to open new page or redirect to a new page using plain javascript without jQuery

Sometimes you need to open a new page or redirect to a webpage using javascript. You can do that without using a library like jQuery

// plain javascript
window.location.replace("http://geek.akhil.me");


// another method
window.location.href = "http://geek.akhil.me";

// if you are insistent on using jquery
$(location).attr('href', 'http://geek.akhil.me')

Published: May 19 2017

blog comments powered by Disqus