$(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="ВКонтакте"',
'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="Одноклассники"',
'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;
}
});
};
});
<div class="share" data-img="/images/tt-fav.png"></div>
сайт.укр/100-щасливий-дeнь-смeрті-2.ком
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
$(document).ready(function() {
if ($(window).width() > 50) {
var LinkTitle = $(document).attr('title');
var LinkUrl = window.location.href;
LinkTitle=encodeURIComponent(LinkTitle);
function fixedEncodeURIComponent (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="ВКонтакте"',
'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="Одноклассники"',
'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;
}
});
};
});
<div class="share" data-img="/images/tt-fav.png"></div>
Чтобы строго соблюдать RFC 3986 (который резервирует !, ', (, ), и *), даже не смотря на то, что символы не используют сформированных URI разделителей, можно безопасно использовать следующее:
function fixedEncodeURIComponent (str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16);
});
}