By agerson on
I would like the cursor to be focused on the username field on the login page. So as soon as the page loads the textfield has focus and a user can start typing in their username without first having to click on the field.
Adam
Comments
This is the gist of it
This is the gist of it (making use of jQuery) to get you started:
--
Erik
If you want the page, every
If you want the page, every time it's loaded, to look for the field and focus in it, this should work fine. You might need to add a class name to your username input field (in the example below I used 'userfield'). I am not that good with javascript, and I am just learning jQuery, so this may not work, but it should ;)
If you have any questions just reply here...
Where do I put this code?
Where do I put this code?
Create a scripts.js file in
Create a scripts.js file in your theme folder and put the following code:
Drupal.behaviors.userNameFocus = function () {
$('#edit-name').focus();
};
Then, in your theme's .info file, put the following line of code:
scripts[] = scripts.js
Works great
thanks for the snippet