<html>
<head>
<title>Untitled</title>
<script language="JavaScript">
function getPosCaret(input){
var range = document.selection.createRange();
var range2 = input.createTextRange();
range2.collapse(true);
range2.moveEnd('character', 0);
range2.setEndPoint('EndToStart', range);
distancia=range2.text.length
pos_final=parseFloat(input.value.length)- parseFloat(distancia)
range2.move('character', pos_final)
return pos_final;
}
</script>
</head>
<body>
<form name="formulario">
<input type="text" name="txt_cursor" value="123456" onkeypress="alert(getPosCaret(this))" style="text-align='right'">
</form>
</body>
</html>
solo funciona con IE pero con Chrome no responde
ResponderEliminar