Убираем из URL адресной строки на странице сайта лишнее
Задача: убрать из адресной строки страницы сайта открытой по ссылке из поисковика Яндекса, «лишнюю» информацию, которая идет «прицепом» от яндекса.
Решение:
<script>
function UrlBrowserYandexCuter(){
path=document.location.pathname.split("yclid");
path=path[0];
search=document.location.search.split("yclid");;
search=search[0];
hash=document.location.hash.split("yclid");;
hash=hash[0];
url=path+search+hash;
if (url.slice(-1)=="?"){
url=url.substring(0, url.length - 1);
};
history.replaceState(null,null, url);
};
UrlBrowserYandexCuter();
</script>