Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Posizionare cursore all'interno di textarea

    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.
    Are you alive?
    No, but I was written with LOVE. A new scripting language.
    www.frequenze.it

  2. #2
    Sorry, proprio domanda sciocca:

    codice:
    document.getElementById('qq').focus();
    Ora pero` il mio dubbio si sposta su un'altra faccenda, perche` questo non funzia su Firefox (su Opera e` OK):

    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>
    Are you alive?
    No, but I was written with LOVE. A new scripting language.
    www.frequenze.it

  3. #3
    Con

    codice:
    <input type="text" value="" id="input" onkeypress="GetTheCode(event);"/>
    funzia anche su Firefox, ma il tasto ESCAPE non viene intercettato... perche`?
    Are you alive?
    No, but I was written with LOVE. A new scripting language.
    www.frequenze.it

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.