DEV Community

101samovar
101samovar

Posted on

Redirect with the same query

How to redirect user from the current page to another page with the same query string using javascript?

document.location = "https://yandex.ru/" + document.location.search
Enter fullscreen mode Exit fullscreen mode

All we need is the document.location object.
The query string is in document.location.search property.
That’s all.


I hope you found this article useful, if you need any help please let me know in the comment section.

πŸ‘‹ See you next time. Have a nice day!

Subscribe to our channel:
https://www.youtube.com/c/Samovar101

Discussion (0)