Ciao, ammettiamo che abbia una textarea con id="qq". Ho un evento controllato da onkeydown, ma quando finisce voglio che il focus sia nuovamente nella textarea, ed esattamente dove era il cursore prima dell'evento. Come sarebbe possibile?
Thx.
Ciao, ammettiamo che abbia una textarea con id="qq". Ho un evento controllato da onkeydown, ma quando finisce voglio che il focus sia nuovamente nella textarea, ed esattamente dove era il cursore prima dell'evento. Come sarebbe possibile?
Thx.
Sorry, proprio domanda sciocca:
Ora pero` il mio dubbio si sposta su un'altra faccenda, perche` questo non funzia su Firefox (su Opera e` OK):codice:document.getElementById('qq').focus();
codice:<html> <head> <script> function GetTheCode(evt){ if(!evt){ evt = event; } if(!evt.which){ evt.which = evt.keyCode; } if(evt.keyCode == '27'){ document.getElementById("key").innerHTML = 'ESCAPE!'; }else{ document.getElementById("key").innerHTML = evt.which; } return false; } </script> </head> <body> <div id="key"></div> <input type="text" value="" id="input" onkeypress="GetTheCode();"/> </body> </html>
Con
funzia anche su Firefox, ma il tasto ESCAPE non viene intercettato... perche`?codice:<input type="text" value="" id="input" onkeypress="GetTheCode(event);"/>