|
Posted by David Dorward on 10/04/07 13:39
On Oct 4, 12:43 am, Adrienne Boswell <arb...@yahoo.com> wrote:
> Here is the scenario. I have an alert that fires if the user has not
> filled in a field. What I would like to do is have the browser focus
> on the message (div id="message").
A div can't hold the focus, it isn't something the user can interact
with.
> That div is generated only if
> there is an error, and the server side code is placed within the
> head. What I think is happening is the js focus is firing BEFORE the
> div is rendered, because I am getting the js error
> document.getElementById("") is null or is not an object.
Well yes. The <script> element tries to access the element, but since
the element doesn't start until after the <script>, it doesn't exist
at that moment.
You would have to move the script so it doesn't fire until the element
exists ... but a div still couldn't hold the focus.
--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/
Navigation:
[Reply to this message]
|