You are here: Re: Focus on element not working correctly « HTML « IT news, forums, messages
Re: Focus on element not working correctly

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация