Onload Form Focus

D

David Mark

David Mark said the following on 12/23/2007 6:09 PM:




Thomas 'PointedEars' Lahn said the following on 12/23/2007 5:29 PM:
ibizara wrote:
Bart Van der Donck [wrote:]
<body onLoad="if (document.getElementById('search'))
document.getElementById('search').focus();">
Perfect and as this is for a local intranet everyone has IE7 so many
thanks works great :)
Nevertheless, it is needlessly inefficient (and error-prone).  Consider this
more efficient and slightly less error-prone solution:
  <body onLoad="var o = document.getElementById('search');
                if (o && o.focus) o.focus();">
Hmm. A "solution" that is still highly error-prone. Maybe you should
Google this thread and read it - in its entirety - to find out why it is
not as "simple" as you portray it to be. Just because an element has a
"focus" property doesn't mean you can set focus to it.
No, but it is something that cannot be stipulated by the developer
(unlike the initial visibility, display and disabled states.)  I am
surprised to see "PointedEars" testing a method by boolean type
conversion though.  We've been over that.

Nothing Thomas does surprises me anymore. And I do mean *nothing*.
Which (as I think you previously mentioned) would be a complete waste
of time (unless you are trying to defend against user style sheets.)

input{
visibility: hidden;
display: none;

}

Damn that was rude :)

If that is in a user style sheet and there are no rules defined in the
application's style sheets, then that would indeed have a rude
effect. The user would have to be a lunatic though.
It does. Tools>Internet Options>General>Accessibility>Format Documents
using my style sheet.

I don't think I've ever seen that.
And he always tries to defend it by saying "I said it was a quick hack"
which usually translates to "I didn't have a clue about it, just wanted
to reply".

That certainly seems the case here. That was the worst "isVisible"
function I have ever seen this side of Prototype. And of course there
was no call for it (the thread should have ended long before that
post.)
 
A

AKS

<sarcasm>
No, no, no. You use setActive(), remember?
</sarcasm>

Yes, I'll never forget. :)
The right conclusion and my solution (which is not intended for the
Code Worth Recommending Project ;) ) have nothing common. OK?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top