maxim1o 0 Posted May 28 Report Share Posted May 28 http://site.ru/ru/example.html Для смены языка на сайте нужно в адресе например /ru/ заменить на /us/ текущий адрес узнаю так <a id="demo"></a> <script> document.getElementById("demo").href= "http://site.ru/us/" + window.location.pathname; </script> Как получить только последнюю часть url? Quote Link to post Share on other sites
1 Solution Switch74 382 Posted May 31 Solution Report Share Posted May 31 window.location.pathname.substr(3) 1 Quote Link to post Share on other sites
0 klierik 435 Posted May 31 Report Share Posted May 31 28.05.2021 в 14:11, maxim1o сказал: Как получить только последнюю часть url? На пример так: window.location.pathname Quote Link to post Share on other sites
Question
maxim1o 0
http://site.ru/ru/example.html
Для смены языка на сайте нужно в адресе например /ru/ заменить на /us/
текущий адрес узнаю так
Как получить только последнюю часть url?
Link to post
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.