Closed Bug 278506 Opened 20 years ago Closed 16 years ago

calling INPUT element's focus method does not work within an onBlur event handler

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 53579

People

(Reporter: manof, Unassigned)

References

()

Details

User-Agent:       Opera/7.54 (Windows NT 5.0; U)  [en]
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

I want to prevent users from leaving an input field empty.
So I've written an event handler for this input field's onBlur event.
In this event handler is an error message displayed and the input fields
is focused again. In MSIE and Opera this works fine, in Mozilla it does not.

Reproducible: Always

Steps to Reproduce:
1. Open the URL above
2. Leave the "Login: " input field empty
3. Press Tab or click outside the input field.
Actual Results:  
The "Login: " input field is not focused.

Expected Results:  
The "Login: " input field should be focused.

There is an inconvenient work-around for this: calling the empty fields focus 
method from window.setTimeout().

Also the following error occurs sometimes within this page:

Error: [Exception... "'Permission denied to get property XULElement.
selectedIndex' when calling method: [nsIAutoCompletePopup::selectedIndex]"  
nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)"  location: "JS frame :: 
http://webappframework.sourceforge.net/bugs/firefox1.0_1.html :: checkEmpty :: 
line 11"  data: no]
This worksforme with a current Linux trunk build.  Is the bug Windows-only?  Or
only a problem in really old geckos (like 1.7.5)?
I still see this in a trunk build on winxpsp2 from 20050120. Dupe of Bug 53579?
Possibly, yes... marking a dep for now.
Depends on: 53579
I'm seeing this bug, too, in FF 1.0.6 on Win2k.
I just fixed my problem by changing code that ran focus() on two sibling <input>
elements to make it focus() just the first one.

So maybe Moz doesn't like focus()'ing two inputs in such quick succession.
[Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a5pre) Gecko/20070515 SeaMonkey/1.5a] (nightly) (W2Ksp4)

Workaround:
{{
			var ceTarget;
			function checkEmpty(pEvent) {
					ceTarget = this;
					setTimeout("ceTarget.focus()", 0);
}}
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
No longer depends on: 53579
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.