How to make links in Cyrillic in the share button?

Here is my js:
$(document).ready(function() {
 if ($(window).width() > 50) { 
 var LinkTitle = $(document).attr('title');
 var LinkUrl = window.location.href;
LinkTitle=encodeURIComponent(LinkTitle);
LinkUrl=encodeURIComponent(LinkUrl);
 var leftvar = (screen.width-600)/2;
 var topvar = (screen.height-400)/2;
 var LinksItem = [
 'http://vkontakte.ru/share.php?url='+LinkUrl+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Vkontakte"',
 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st._surl='+LinkUrl+'&title='+LinkTitle+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Odnoklassniki"',
 'http://connect.mail.ru/share?share_url='+LinkUrl+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Mail.ru"',
 'http://www.facebook.com/sharer.php?u='+LinkUrl+'&t='+LinkTitle+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Facebook"',
 'http://twitter.com/share?text='+LinkTitle+'&url='+LinkUrl+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Twitter"',
 'https://plus.google.com/share?url='+LinkUrl+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Google"',
 'http://www.livejournal.com/update.bml?event='+LinkUrl+'&subject='+LinkTitle+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Livejournal"'
];
$('.share').each(function(){
 var $share = $(this);
 var $urlImg = $share.attr("data-img");
 var sdvig = 0;
 for (i=0; i<LinksItem.length; i++)
{
 var getLinks = $('<a href="'+LinksItem[i]+' style="background: url('+$urlImg+') -'+sdvig+'px top no-repeat;" target="_blank"></a>');
getLinks.appendTo($share);
 var sdvig = sdvig + 27;
}
});
};
});

Displayed on the website like this:
<div class="share" data-img="/images/tt-fav.png"></div>


The website has links like this: website.Ukr/100-happy-day-smart-2.kom

And gives me a button that
https://xn00000.xn--j1amh/100-%D1%89%D0%B0%D1%81%D0%BB%D0%B8%D0%B2%D0%B8%D0%B9-%D0%B4e%D0%BD%D1%8C-%D1%81%D0%BCe%D1%80%D1%82%D1%96-2.%D0%BA%D0%BE%D0%BC


Prescribed 00000 to not think that it is.
Please help me to solve it.
March 19th 20 at 09:19
2 answers
March 19th 20 at 09:21
Solution
Will oprosu the answer to any js or add in Novi
$(document).ready(function() {
 if ($(window).width() > 50) { 
 var LinkTitle = $(document).attr('title');
 var LinkUrl = window.location.href;
LinkTitle=encodeURIComponent(LinkTitle);
 fixedEncodeURIComponent function (LinkUrl) {
 return encodeURIComponent(LinkUrl).replace(/[!'()*]/g, function(c) {
 return '%' + c.charCodeAt(0).toString(16);
});
}
 var leftvar = (screen.width-600)/2;
 var topvar = (screen.height-400)/2;
 var LinksItem = [
 'http://vkontakte.ru/share.php?url='+LinkUrl+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Vkontakte"',
 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st._surl='+LinkUrl+'&title='+LinkTitle+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Odnoklassniki"',
 'http://connect.mail.ru/share?share_url='+LinkUrl+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Mail.ru"',
 'http://www.facebook.com/sharer.php?u='+LinkUrl+'&t='+LinkTitle+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Facebook"',
 'http://twitter.com/share?text='+LinkTitle+'&url='+LinkUrl+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Twitter"',
 'https://plus.google.com/share?url='+LinkUrl+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Google"',
 'http://www.livejournal.com/update.bml?event='+LinkUrl+'&subject='+LinkTitle+'" onClick="popupWin = window.open(this.href, \'contacts\', \'location,width=600,height=400,left='+leftvar+',top='+topvar+'\'); popupWin.focus(); return false;" title="Livejournal"'
];
$('.share').each(function(){
 var $share = $(this);
 var $urlImg = $share.attr("data-img");
 var sdvig = 0;
 for (i=0; i<LinksItem.length; i++)
{
 var getLinks = $('<a href="'+LinksItem[i]+' style="background: url('+$urlImg+') -'+sdvig+'px top no-repeat;" target="_blank"></a>');
getLinks.appendTo($share);
 var sdvig = sdvig + 27;
}
});
};
});

picture
5c9fabb629c73980183358.png
vivodina so
<div class="share" data-img="/images/tt-fav.png"></div>


get
https://xn00000.xn--j1amh/100-щасливий-дeнь-смeрті...

the domain itself is not to translate it would be in another question
March 19th 20 at 09:23
To design independently the get parameters in the link you need to fully comply with the standard character encoding RFC 3986.
On the server side is as follows:
https://www.php.net/manual/ru/function.rawurlencode.php
https://www.php.net/manual/ru/function.rawurldecode.php
On the client side like this:
https://developer.mozilla.org/ru/docs/Web/JavaScri...

To strictly adhere to RFC 3986 (which reserves !, ', (, ), and *), even despite the fact that the characters do not use the formed URI delimiters, you can safely use the following:

fixedEncodeURIComponent function (str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16);
});
}
put
fixedEncodeURIComponent function (LinkUrl) {
return encodeURIComponent(LinkUrl).replace(/[!'()*]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16);
});
}

instead
LinkUrl=encodeURIComponent(LinkUrl);
got
https://xn00000.xn--j1amh/100-щасливий-дeнь-смeрті...
the domain aperiodic - Carmella commented on March 19th 20 at 09:26
@Carmella, but not transfer You domain!!! Well, as You know. - Eda commented on March 19th 20 at 09:29

Find more questions by tags JavaScript