how-to ยท javascript

How-to redirect using javascript?

Problem:

You need to redirect user using javascript.
Using vanilla JS, jQuery not nessesary

Solution 1:

Use this if you NOT need to put page to history

// similar behavior as an HTTP redirect
window.location.replace("http://blog.nektodev.ru");  

Solution 2:

Use this if you need to put page to history

// similar behavior as clicking on a link
window.location.href = "http://blog.nektodev.ru";  

Read Also:

Published:
comments powered by Disqus