[pmwiki-users] Edit modes question. How to jump to end of textarea automacticly

Hans design5 at softflow.co.uk
Tue Aug 29 12:02:31 CDT 2006


I played around as well and came up with this code snippet, to be
added to config.php. For ?action=edit&cursor=end Firefox does just
that, but IE puts the cursor at the beginning of the text. I could not
persuade IE to focus and at t he sam etime jump to the end.
Anyway, here is the code. It redefines $InputTags['e_textarea']

# jump to end of edit textarea when ?action=edit&cursor=end
if (isset($_GET['cursor'])) $cs = $_GET['cursor'];
if($cs=='end') {
   XLSDV('en', array(
     'ak_save' => 's',
     'ak_saveedit' => 'u',
     'ak_preview' => 'p',
     'ak_textedit' => 'e',
     'e_rows' => '23',
     'e_cols' => '60'));

   $InputTags['e_textarea'] = array(
     ':html' => "<textarea \$InputFormArgs 
       onkeydown='if (event.keyCode==27) event.returnValue=false;' 
       >\$EditText</textarea>
        <script language='javascript' type='text/javascript'><!--
           element = document.getElementById('text');
           try { element.focus(); }
           catch(e) { element.focus(); }
           element.scrollTop = element.scrollHeight; 
        --></script>
       ",
     'name' => 'text', 'id' => 'text', 'accesskey' => XL('ak_textedit'),
     'rows' => XL('e_rows'), 'cols' => XL('e_cols'));
}

# end of code snippet #

If you want this behaviour all the time without needing to use
&cursor=end you could remove the conditionals at the beginning, and
the bracket at the end.

Hans





More information about the pmwiki-users mailing list