Yes, I tried it exactly as you explained and I also looked at the Google
site to read their code.
It is still not working.
Could it have anything to do with the type of text box?
Below is the exact code that I'm using:
<body>
...... other stuff
<!-- jco; This creates a form that contains a text field and 2-buttons to
validate users input -->
<FORM NAME="frmPassword" onEnter="return valForm()">
<!-- jco; Add two buttons and a text field -->
<p align="center">
<input type=password name="txtInput" size="28" onkeypress="onEnter();" ></p>
<p align="center">
<input type="button" value="Enter Password" name="btnEnter"
onclick="valForm();">
<input type="reset" value="Clear" name="btnClear"></p>
</form>
<!-- jco; Setfocus to text box so user can quickly sign in -->
<body onload=document.frmPassword.txtInput.focus()>
</body>
Note:
I just moved the onload to the bottom. Now it works, however, the cursor
keeps blinking. There is animaiton on the top frame. The cursor seems to
blink with the animation.
Should I move the line of code back to the top; Before the form?
Or should I manage the blinking ... somehow?
"mscir" <mscir@access4less.net> wrote in message
news:102nr00s8vaq122@corp.supernews.com...[color=blue]
> JCO wrote:[color=green]
> > Nothing I do, puts the cursor in the text box. Seems strange.
> > I tried moving the onLoad to the bottom .. below the creation of the[/color][/color]
form.[color=blue][color=green]
> > It made no difference so I put it back at the beginning of the body.
> >
> > Still not working![/color]
>
> Try the approach google uses (view source - relevant code shown).
>
> <html>
> <head>
> <title>Google</title>
> <script>
> <!--
> function sf(){document.f.q.focus();}
> // -->
> </script>
> </head>
> <body onLoad=sf()>
> <form action="/search" name=f>
> <input maxLength=256 size=55 name=q value="">
> </body>
> </html>
>[color=green]
> >
> > "Randy Webb" <hikksnotathome@aol.com> wrote in message
> > news:DY6dnTGriYcdvrfdRVn-vg@comcast.com...
> >[color=darkred]
> >>McKirahan wrote:
> >>
> >>>" JCO" <J.Oliviero@verizon.net> wrote in message
> >>>news:UVjWb.4513$1B6.1175@nwrddc03.gnilink.net.. .
> >>>
> >>>
> >>>>I have a text box, on my form that I cant get the focus on. I'm using[/color]
> >
> > it
> >[color=darkred]
> >>>as
> >>>
> >>>
> >>>>shown:
> >>>><head>
> >>>><body onload=document.getPassword.txtPasswordName.focus( )>
> >>>></head>
> >>>>
> >>>>Where
> >>>>getPassword is the form &
> >>>>txtPasswordName is the text box
> >>>>
> >>>>Why is this? Anyone know a better way of doing this?
> >>>
> >>>
> >>>
> >>>You probably can't use "onload=" as the form isn't loaded.
> >>
> >>Since onload events only happen after the document is loaded (thats what
> >>its for), then the form is indeed loaded.
> >>
> >>
> >>OP:
> >>One major problem, and may/may not be part of the source of the problem,
> >>is that the body tag goes after the </head> tag, the body is not part of
> >>the head section. Although most browsers error correct soup code and
> >>close the head when it encounters the body tag. Validate HTML before
> >>complaining about javascript.
> >>
> >>It also will depend on whether getPassword is the name or the id of the
> >>form (It matters). Same for txtPasswordName.
> >>
> >>Validate your code, after its valid, if it still doesn't set focus, post
> >>the minimum code (or a URL) to the offending page.
> >>
> >>--
> >>Randy
> >>Chance Favors The Prepared Mind
> >>comp.lang.javascript FAQ -
http://jibbering.com/faq/[/color][/color]
>[/color]