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

VERIFIED FIXED in mozilla1.8beta1

Status

()

Core
Event Handling
P1
normal
VERIFIED FIXED
14 years ago
12 years ago

People

(Reporter: David Brittain, Assigned: bz)

Tracking

({regression})

Trunk
mozilla1.8beta1
regression
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

14 years ago
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
(Reporter)

Comment 1

14 years ago
Created attachment 170614 [details]
test case
(Reporter)

Updated

14 years ago
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
(Reporter)

Comment 4

14 years ago
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.

Comment 5

14 years ago
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.
Created attachment 173010 [details] [diff] [review]
Fix

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
Last Resolved: 13 years ago
Resolution: --- → FIXED
(Reporter)

Comment 9

13 years ago
Verified fixed Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8b)
Gecko/20050201 Firefox/1.0+
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.