Código:
<script>
contenido_textarea = ""
num_caracteres_permitidos = 140
function valida_longitud(){
num_caracteres = document.forms[0].texto.value.length
if (num_caracteres <= num_caracteres_permitidos){
contenido_textarea = document.forms[0].texto.value
}else{
document.forms[0].texto.value = contenido_textarea
}
if (num_caracteres >= num_caracteres_permitidos){
document.forms[0].caracteres.style.color="#ff0000";
}else{
document.forms[0].caracteres.style.color="#A5ACB2";
}
cuenta()
}
function cuenta(){
document.forms[0].caracteres.value=document.forms[0].texto.value.length
}
function gotwitter()
{
window.location='http://twitter.com/home?status='+document.forms[0].texto.value+''
}
</script>
<style>
#cuentanro{float:right;color:#A5ACB2;}
.cuentanro2{font-family:arial;font-size:14pt;border:0px;color:#A5ACB2;}
#botonpublicar {float:right;margin-top:10px;background:#F6F6F6;border:#D9D9D9;border-style:solid;border-width:1px;text-decoration:none;padding:5px 10px 5px 15px;font-size:15px;font-family:"lucida grande",helvetica,tahoma,arial;display:inline-block;_display:inline;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;line-height:16px; color:#999999;}
#botonpublicar:hover{float:right;margin-top:10px;background:#A5ACB2;border:#EBEBEB;border-style:solid;border-width:1px;text-decoration:none;padding:5px 10px 5px 15px;font-size:15px;font-family:"lucida grande",helvetica,tahoma,arial;display:inline-block;_display:inline;-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px;line-height:16px; color:#fff;}
.textotxt{font-family:arial;font-size:10pt}
</style>
<form action="#" method="yyy"><img SRC="http://a0.twimg.com/a/1269281712/images/twitter_logo_header.png" style="width: 75px; height: 15px;"/>
<div id="cuentanro">
<input type="text" class="cuentanro2" value="140" name="caracteres" size="1" />
</div>
<textarea style="width:98%; height:60px" class="textotxt" name="texto" onkeydown="valida_longitud()" onkeyup="valida_longitud()"></textarea><br />
<a id="botonpublicar" href="#" onclick="gotwitter()">Publicar en twitter</a>
<a style="color:#ddd;padding:10px 0 0 10px;font-size:10pt" href="http://loseasi.blogspot.com/2010/03/envia-twitter-mensajes-desde-el-blog.html" target="_blank">Widget</a>
</form>
Ver ejemplo:
0 comments:
Post a Comment