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

Hans design5 at softflow.co.uk
Tue Aug 29 15:51:31 CDT 2006


Here is an improved version of what I posted before.
This works both in Firefox and IE6,
with help of some nifty javascript.
Again if you want to jump to the end of text always when editing,
remove both "if" lines at the top, and the } bracket at the end.
Add to config.php:


# 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'><!--
         el = document.getElementById('text');
         ln = el.value.length;
         try { el.focus(); }
         catch(e) { el.focus(); }
         el.scrollTop = el.scrollHeight;
         if (el.createTextRange) {
             var rg = el.createTextRange();
             rg.collapse(true);
             rg.moveEnd('character',ln);
             rg.moveStart('character',ln);
             rg.select();
         }
     --></script>
        ",
     'name' => 'text', 'id' => 'text', 'accesskey' => XL('ak_textedit'),
     'rows' => XL('e_rows'), 'cols' => XL('e_cols'));
}






More information about the pmwiki-users mailing list