You're right. I made this little html page to demonstrate. I guess this has
nothing to do with Tapestry, but may be of concern to people.
Demo page:
<html><head><title>Boogie Funk Experiment squared</title></head>
<BODY>
<form id="funkyform">
<div id="someDiv" style="display:none">
<input type="checkbox" id="theCheck"/>Checkbox!<br/><br/>
</div>
</form>
<script language="JavaScript" type="text/javascript"><!--
document.getElementById('theCheck').focus();
// --></script>
</BODY>
</html>
Another interesting thing: if I take out the display:none for the div around
the checkbox, firefox will actually put the focus on the checkbox. You can
check it with the space bar. IE won't error, but it won't really focus on
the checkbox either. Setting the div display in javascript works fine, but
it's kind of a pain. It might be better to just turn the focusing off for
now than to use javascript to hide things.
<html><head><title>Boogie Funk Experiment squared</title></head>
<BODY>
<form id="funkyform">
<div id="someDiv" style="">
<input type="checkbox" id="theCheck"/>Checkbox!<br/><br/>
</div>
</form>
<script language="JavaScript" type="text/javascript"><!--
document.getElementById('theCheck').focus();
document.getElementById('someDiv').style.display = 'none';
// --></script>
</BODY>
</html>
On 10/28/05, Schulte Marcus <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I've had the very same problem recently. Yes, the display:none - DIV does
> matter. In my case, I had a form that was initially invisible to have less
> clutter on the page.
>
> My current workaround is to set the form to display:none in javascript
> instead of CSS on loading in a custom script's initialization-part only
> after the focus is set. You have to put the @Script after the @Form to
> accomplish this. A minor drawback is, that you can have a bit of flicker
> on
> page-loading, when your invisible parts are displayed for a fraction of a
> second
>
> hth,
> Marcus
>
> > -----Original Message-----
> > From: Chris Norris [mailto:[EMAIL PROTECTED]
> > Sent: Friday, October 28, 2005 3:58 PM
> > To: Tapestry users
> > Subject: focus problems in forms
> >
> >
> > When I have a form with only check boxes and submit buttons,
> > IE reports
> > javascript errors because the focus is trying to be set to a
> > control that is
> > invisable, disabled, or cannot accept focus. The thing is,
> > it's trying to
> > set the focus to a checkbox. The checkbox looks like this in
> > rendered html:
> >
> > <input type="checkbox" name="Checkbox" id="Checkbox"
> > class="normalCheckBox"/> Create ....blahblahblah
> >
> > The script at the bottom of the html looks like so:
> >
> > <script language="JavaScript" type="text/javascript"><!--
> > Tapestry.register_form('formThing');
> > Tapestry.set_focus('Checkbox');
> > // --></script></body>
> >
> > This makes no sense to me. Shouldn't I be able to focus on
> > the checkbox? I
> > could set focus to false for the form, but that's not really the best
> > solution here. The only odd thing about the checkbox is that
> > it's initiall
> > in a div that is hidden like so:
> >
> > <div id="someDivId" style="display: none;">
> >
> > I wouldn't think that would matter, though. This works fine in FF.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>