469,964 Members | 1,754 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

Tab jumping to address bar, not next field after select() [IE]

I am using select()/focus() to position the cursor at a particular field
on a form. This works, but when the user presses the Tab key in IE the
cursor jumps to the address bar rather than the next field (Firefox is
fine). Does anyone know why this might be happening and how to stop it?

Below is the code that I use to set the cursor position (it is somewhat
convoluted because it is generated via a series of macros). The cursor
is positioned correctly, but when I hit Tab the cursor does not follow
the expected flow through the page (i.e. it doesn't go to the next field).

// The page contains:
<script language="JavaScript1.2" type="text/javascript">
<!--
var focusId = 'fnameId';
SafeAddOnload(setFocus);
//-->
</script>
<input id="fnameId" type="text" size="50" name="fname" value="" />

// From a .js file loaded by the page:
// SafeAddOnload (used above) just delays execution until the
// page has loaded.
// getRef (used below) simply retrieves the DOM object using the id.
//
function setFocus()
{
obj = getRef(focusId);
if (obj != null)
try
{
obj.select();
}
catch (e)
{
obj.focus();
}
}

Thanks in advance for any assistance.

Scott
Jul 23 '05 #1
2 11245

Set a tabindex= on your inputs or just 1 input or so, to the tabpress
gets trapped and passed to the tabindex pool, plain html:

<input tabindex="1"> <input tabindex="2">
when the user presses the tab, it'll use 1 and 2 indexed elements for
jumping, leaving out the address box.
Danny
On Wed, 13 Jul 2005 19:27:01 -0700, Scott Eade <se***@westnet.com.au>
wrote:
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #2
Danny wrote:

Set a tabindex= on your inputs or just 1 input or so, to the
tabpress gets trapped and passed to the tabindex pool, plain html:

<input tabindex="1"> <input tabindex="2">
when the user presses the tab, it'll use 1 and 2 indexed elements
for jumping, leaving out the address box.
Danny

Thanks for the suggestion Danny. I had tried using tabindex and it
still misbehaved.

I have just spent a couple more hours on this and have isoated it down
to the setFocus() implementation - specifically to the exception
handling. The following replacement code makes it work:

function setFocus()
{
var obj = getRef(focusId);
if (obj != null) {
obj.focus();
if (obj.select)
obj.select();
}
}

Looks like the exception handling in IE is a little screwed up.

Scott
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Steve Lefevre | last post: by
3 posts views Thread by scott_baird | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.