Last updated October 18, 2011. Created by ugerhard on February 7, 2006.
Edited by MGParisi, bekasu, bjornarneson. Log in to edit this page.
This php snippet will automatically give focus to the username field when anonymous users visit www.example.com/?q=user.
The snippet should be inserted immediately before the <?php print $closure;?> tag in your page.tpl.php.
<?php
// If user is not logged in and visits user page,
// focus caret on username text input.
if ((arg(0) == "user") && (!$user->uid)) {
print "[script type=\"text/javascript\"]\n";
print "document.getElementById('edit-name').focus()\n";
print "[/script]\n";
}
?>