vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Can the Username Field be made Active upon Page Load? (https://vborg.vbsupport.ru/showthread.php?t=88786)

Ocean 03-28-2004 07:10 PM

Can the Username Field be made Active upon Page Load?
 
When someone brings up the main vB 3.0 page, I would like the Username field to be automatically active. The focus should be there - that way as soon as the page loads, users can just start typing in order to log themselves in.

Can this be done without getting in the way of anything else that happens upon page load?

wnorris 03-29-2004 05:57 AM

not too terribly difficult... you'll be editing the "navbar" template (about a quarter of the way down through the file). first you need to add a "name" attribute to the login form...

HTML Code:

<!-- login form -->
                <form action="login.php" method="post" onsubmit="md5hash(vb_login_password,vb_login_md5password)">

changes to

HTML Code:

<!-- login form -->
                <form action="login.php" method="post" name="vb_login_form" onsubmit="md5hash(vb_login_password,vb_login_md5password)">


Then just add the following javascript to the end of the login form section...

HTML Code:

                <script type="text/javascript">
                document.vb_login_form.vb_login_username.focus();
                </script>
                <!-- / login form -->


Ocean 03-29-2004 10:20 AM

Wnorris, thank you!

That did the job quite well. :)


Out of curiosity, on a similar question posted at vB.com - the concern came up that some vB elements require the onLoad in the body tag, and this mod was assumed to need to be triggered onLoad.

Is there any concern that the code you provided will interfere with any other elements?

wnorris 03-30-2004 10:40 AM

not at all... the onLoad portion of the body tag will be called regardless. the only time you might have a problem is if you had another element trying to get focus, in which case the last one to call focus() wins.


All times are GMT. The time now is 09:00 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01241 seconds
  • Memory Usage 1,715KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete