Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

autofocus doesn't work

Started by Sir Osis of Liver, June 17, 2022, 10:19:11 PM

Previous topic - Next topic

Sir Osis of Liver

Trying to autofocus Username input field in login popup, no luck.  Here's the code:

        echo '<script type="text/javascript" src="', $settings['theme_url'], '/scripts/sha1.js"></script>
                <form id="guest_form" action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
                <label for="popupwindows" class="teknoromibutton">Admin</label>
                <input type="checkbox" class="teknoromiwindows" id="popupwindows" name="popupwindows"/>
                <label class="popupwindows">
                    <span style="float: left; margin-top: 10px;">Username:</span><input name="user" class="form-text" type="text" />
                    <span style="float: left; margin-top: 24px;">Password:</span><input name="passwrd" class="form-text" type="password"/>
                    <input type="submit" value="', $txt['login'], '" class="button_submit" />';

The Admin button opens the popup.  Html autofocus doesn't work, tried several js solutions, no good.  Works fine otherwise.

"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns


Use Javascript to set the focus.

Sir Osis of Liver

Tried half dozen js tricks, none worked.  This is the old mobile-desktop theme.  Not a big deal, just annoying. >:(

"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns