Revista Empresa

★ Barra social en Javascript

Publicado el 26 diciembre 2011 por Albertllueca

Hoy he hecho una barra social en Javascript, ahí os la dejo…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<script type="text/javascript">
var twtTitle  = document.title;
var twtUrl    = location.href;
var maxLength = 140 - (twtUrl.length + 1);
if (twtTitle.length > maxLength) {
twtTitle = twtTitle.substr(0, (maxLength - 3))+'...';
}
var twtLink = 'http://twitter.com/home?status='+encodeURIComponent(twtTitle + ' ' + twtUrl);
document.write('<a href="'+twtLink+'" target="_blank"'+'><img src="tw.png"  border="0" alt="Tweet This!" /'+'><'+'/a>');
twtUrl = twtUrl.replace("/", "%2f");
twtUrl = twtUrl.replace(":", "%3A");
document.write('<a id="plusone-icon" class="pngfix" style="" title="PlusOne" href="https://plusone.google.com/_/+1/confirm?hl=es&url='+twtUrl.replace("/", "%2f")+'"><img src="go.png"  border="0" alt="Comparte!"/></a>');
document.write('<a href="https://www.facebook.com/sharer/sharer.php?u='+twtUrl+'&t='+twtTitle+'" target="_blank"'+'><img src="fb.png"  border="0" alt="Comparte!" /'+'><'+'/a>');
</script>


Volver a la Portada de Logo Paperblog