Closed Bug 190774 Opened 22 years ago Closed 15 years ago

focus() is not working

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
All
defect
Not set
major

Tracking

()

RESOLVED FIXED

People

(Reporter: baram01, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: access)

Attachments

(1 file)

User-Agent:       Mozilla/4.0 (compatible; MSIE 5.0; Linux) Opera 6.02  [en]
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003

I have added Javascript code to set focus to particular objects within the 
page when data entered does not meet particular criteria.  It works in ver 
1.0, and every other browser that do not use mozilla as the core engine.

Reproducible: Always

Steps to Reproduce:
1.  create a web page using the following in the page
<html>
<script language="JavaScript">
function _check()
{
   var form = document.user;
   var ret = true;

   if ( form.test2.value != form.test1.value ) {
         alert("Values does not match");
         form.test1.value = form.test2.value = "";
         form.test1.focus();
   }
}
</script>
<form name="user">
<input type="text" name="test1" size=25>
<input type="text" name="test2" size=25 onchage="_check(this)">
<unput type="test" name="test3" size=25>
</form>
</html>

2.  Point the mozilla browser to this page.
3.  Test the page.

Actual Results:  
It does not focus on "test1"

Expected Results:  
Keyboard focus should have transfered to "test1" and went on to "test3".
Attached file Tabing block focus()
Sorry, I fix 3 typos in you code. If you put some data in first field, that
some data in second one -- and press enter, focus work O'k. Also if you press
mouse after typing. But if you press TAB, focus goes to next (3rd) field.
Using Mozilla trunk binary 2006011708 on WinNT. 
Confirming reported behavior. OS: Linux ---> All.

Note the DOM method focus() does work in isolation.
If I try this javascript:URL, for example:

   javascript: document.user.test1.focus();

Then focus goes to the right field. But when called from the
onChange() event handler, focus does not go consistently to test1.

Not sure if this should go to DOM Events or DOM Level 0. Let me reassign
to the latter for further analysis. Note the testcase works in IE6 and NN4.7. 
That is, after entering unequal data in test1 and test2, focus is brought
back to test1, as desired -
Assignee: rogerl → jst
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → DOM Level 0
Ever confirmed: true
OS: Linux → All
QA Contact: pschwartau → desale
Same on MacOS 9, Build 2003012212
to keyboard nav
Assignee: jst → aaronl
Component: DOM Level 0 → Keyboard: Navigation
QA Contact: desale → sairuh
-> Bryner, focus
Assignee: aaronl → bryner
Blocks: focusnav
dup of Bug 65581?
Bryner, is this bug important for us to fix?
After fixing Bug 53579, this behavior has been changed.

If you put some data in 1st field, another data in 2nd field,
and press Tab, then cursor blinks in 1st field.  But text is entered
in 3rd field.
If you press Enter instead of Tab, no problem occurs.
2003081104/WinNT

Dup of Bug 147927?
*** Bug 215380 has been marked as a duplicate of this bug. ***
Same here with firefox 0.9 and windows XP. and on Debian Linux Unstable

the  if i ushe the onBlur to validate and kick back the focus on the fild if
it's wrong, the focus will not go back to the control if i have clicked on
another control (wich is whey the onblur is called because my control has lose
his focus)
This sounds similar to Bug 311956, which was mistakenly flagged as "resolved".
Assignee: bryner → mats.palmgren
Keywords: access
The testcase fails in a 20090609 build (before new focus manager landing)
The testcase works in a 20090611 build (after new focus manager landing)
I think this was fixed by the new focus manager (bug 178324).

-> FIXED
Assignee: matspal → nobody
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Component: Keyboard: Navigation → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: