Ver Mensaje Individual
  #1 (permalink)  
Antiguo 31/05/2013, 07:12
viperracing
 
Fecha de Ingreso: septiembre-2010
Mensajes: 8
Antigüedad: 13 años, 7 meses
Puntos: 0
Crear boton de Twitter personalizado con Popup centrado

Hola estoy intentando combinar dos codigos que tengo pero me falla un detalle y necesito ayuda

Conseguí realizar los cambios necesarios en este codigo que me permite enlazar a Facebook pero ahora lo hace como popup centrado

Código:
<script type="text/javascript">
function fbs_click(width, height) {
    var leftPosition, topPosition;
    //Allow for borders.
    leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
    //Allow for title and status bars.
    topPosition = (window.screen.height / 2) - ((height / 2) + 50);
    var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";
    u=location.href;
    t=document.title;
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer', windowFeatures);
    return false;
}
</script>

<a href="http://www.facebook.com/share.php?u=<full page url to share" onClick="return fbs_click(450, 350)" target="_blank" title="Share This on Facebook"><img src="/ico/facebook-icon.jpg" alt="facebook share"></a>
Ahora necesito hacer lo mismo con el de Twitter pero tengo un pequeño problema

Me explico, este Codigo: me permite enlazar a twitter con mi icono personalizado sin popup pero capturando automaticamente la web/exacta que quiero enlazar y su nombre

Código:
<a href="javascript:var dir=window.document.URL;var tit=window.document.title;var tit2=encodeURIComponent(tit);var dir2= encodeURIComponent(dir);
window.location.href=('http://twitter.com/?status='+tit2+'%20'+dir+'');"><img src="/ico/twitter-icon.jpg" border="0" width="35" height="28" alt="Compartir" /></a>
Este otro hace lo mismo pero con pop-up centrado, pero me da un problema que no consigo depurartiene que ser alguna tontería pero le e dado 20 vueltas y no me sale

Código:
<script type="text/javascript">
function fbs_click(width, height) {
    var leftPosition, topPosition;
    //Allow for borders.
    leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
    //Allow for title and status bars.
    topPosition = (window.screen.height / 2) - ((height / 2) + 50);
    var windowFeatures = "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no";
    u=location.href;
    t=document.title;
    window.open('http://twitter.com/?status=?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer', windowFeatures);
    return false;
}
</script>

<a href="http://twitter.com/?status=?u=<full page url to share" onClick="return fbs_click(450, 400)" target="_blank" title="Share This on Twitter"><img src="/ico/twitter-icon.jpg" alt="twitter share"></a>

este codigo funciona pero no me muestra el nombre de la web enlazada correctamente como hace el primer codigo de twiter

Este es el error:

Código:
?u=http://miweb.com/subpagina.html
debería de quedar asi (como en el primer codigo):

Código:
 Nombre de la Pagina - Nombre de la web http://miweb.com/subpagina.html
No se porque no se cumple la función que inserta el nombre de la pagina y me pone esto:

Código:
?u
Muchas gracias un saludo y espero que esto sirva si lo solucionamos.