Closed Bug 277482 Opened 20 years ago Closed 20 years ago

[FIX]Input field does not get focus set by Javascript on load

Categories

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

defect

Tracking

()

VERIFIED FIXED
mozilla1.8beta1

People

(Reporter: mozilla, Assigned: bzbarsky)

Details

(Keywords: regression)

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a6) Gecko/20050106 Firefox/1.0+
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8a6) Gecko/20050106 Firefox/1.0+

MS Exchange webmail uses html like that attached in Firefox 1.0 (and IE 6) the
input filed has focus set when the page loads. This means you can immediately
start typing your username. In FF 1.0+ focus is not set, and you have to
manually set it before typing.

Reproducible: Always

Steps to Reproduce:
1. Load the attached html file
2. 
3.

Actual Results:  
focus is not set on input field

Expected Results:  
focus should be set on input files
Attached file test case
Keywords: regression
use a different method:
(your method is the IE-way, this is the W3C way)

<html>
<body>
<form name="logonForm">
	<input name="mailbox" value="" size="20" type="text">
	<script language="JavaScript">
		document.forms[0].elements[0].focus();
	</script>
</form>
</body>
</html>

works fine

INVA ?
or when you prefer to call elements direct

<html>
<body>
<form id="logonForm">
	<input id="mailbox" value="" size="20" type="text">
	<script type="text/javascript">
		document.forms['logonForm'].elements['mailbox'].focus();
	</script>
</form>
</body>
</html>
Assignee: bugs → events
Component: Form Manager → Event Handling
Product: Firefox → Core
QA Contact: form-manager → ian
Version: unspecified → Trunk
Thanks for the explanation as to why it does not work. However, why has the
behaviour changed? A lot of people use MS webmail, and this change means that
you have to reach for the mouse while logging in.
document.formName.formElementName is not "the IE-way", it's as old as
JavaScript: the testcase works as expected in Navigator 2.02. 
Regression window: works in 1.8a2 2004052410, fails in 1.8a2 2004052810.
Attached patch FixSplinter Review
This regressed when FlushPendingNotifications got more fine-grained.  We used
to flush out everything for the content list accesses in that JS, now we just
flush content.

The result is that frames may not be up-to-date yet when focus() is called.  So
we should make sure to flush them out in focus().
Assignee: events → bzbarsky
Status: NEW → ASSIGNED
Attachment #173010 - Flags: superreview?(jst)
Attachment #173010 - Flags: review?(jst)
OS: Windows XP → All
Priority: -- → P1
Hardware: PC → All
Summary: Input field does not get focus set by Javascript on load → [FIX]Input field does not get focus set by Javascript on load
Target Milestone: --- → mozilla1.8beta
Comment on attachment 173010 [details] [diff] [review]
Fix

r+sr=jst
Attachment #173010 - Flags: superreview?(jst)
Attachment #173010 - Flags: superreview+
Attachment #173010 - Flags: review?(jst)
Attachment #173010 - Flags: review+
Fixed.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Verified fixed Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b)
Gecko/20050201 Firefox/1.0+
Status: RESOLVED → VERIFIED
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: