Autofocus 2001

jlewis@lewis.org jlewis@lewis.org
Tue, 15 May 2001 09:40:01 -0400 (EDT)


I think I just reinvented a 2 year old wheel.  The webmistress has been
bugging me to make the Username field on the login page focused on page
load.  I just did some hacking on IMP 2.2.3 to do this, then searched the
list archive to see if it's been discussed before.  It seems it was back
in June 1999.  Using Netscape 4.76 on Linux, I'm not seeing the random
tabstop issue...and it's a pretty safe bet that most of our users are
using IE anyway.

Here's how I did it.  Is there a better way?

--- lib/horde.lib.orig  Tue May 15 09:25:31 2001
+++ lib/horde.lib       Tue May 15 09:20:28 2001
@@ -622,7 +622,7 @@
   var $vlink_color = ''; /* vlink color */
   var $alink_color = ''; /* alink color */

-  function generate_body() {
+  function generate_body($earg = "") {
     echo '<body';
     if ($this->bg_file) echo ' background="' . $this->bg_file . '"';
     if ($this->bg_color) echo ' bgcolor="' . $this->bg_color . '"';
@@ -630,7 +630,7 @@
     if ($this->link_color) echo ' link="' . $this->link_color . '"';
     if ($this->vlink_color) echo ' vlink="' . $this->vlink_color . '"';
     if ($this->alink_color) echo ' alink="' . $this->alink_color . '"';
-    echo ">\n";
+    echo ' ' . $earg . ">\n";
   } /* END function generate_body() */

   function start () {

--- imp/templates/login/login.inc.orig  Tue May 15 09:26:32 2001
+++ imp/templates/login/login.inc       Tue May 15 09:23:40 2001
@@ -49,7 +49,7 @@

 </head>

-<?php $default->body->generate_body(); ?>
+<?php $default->body->generate_body('onLoad="document.implogin.imapuser.focus()"'); ?>

 <noscript>
 <p><b><?php echo $lang->javascript_needed; ?></b></p>


-- 
----------------------------------------------------------------------
 Jon Lewis *jlewis@lewis.org*|  I route
 System Administrator        |  therefore you are
 Atlantic Net                |
_________ http://www.lewis.org/~jlewis/pgp for PGP public key_________