O'Reilly logo

Drupal 6 Theming Cookbook by Karthik Kumar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Giving the username textfield keyboard focus

This recipe will detail how keyboard focus can be assigned to the username field in the login block. This will ensure that the user does not need to use the mouse or tab through the page to log in to the site.

Getting ready

We will be using the mysite module created earlier in this book to hold our odds and ends. It is assumed that this module has been created and is enabled.

How to do it...

The following steps are to be performed inside the mysite module folder at sites/all/modules/mysite.

  1. Create if necessary, and navigate to the JavaScript folder at sites/all/modules/mysite/js.
  2. Create a JavaScript file named userfocus.js and open it in an editor.
  3. Add or merge the following JavaScript to the file:
    Drupal.behaviors.mysiteUserFocus ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required