Open Bug 181489 Opened 22 years ago Updated 2 years ago

handle body.onload events messing with user input

Categories

(Core :: Layout: Form Controls, enhancement, P4)

x86
Windows XP
enhancement

Tracking

()

REOPENED
Future

People

(Reporter: neil, Unassigned)

References

()

Details

text is lost if onload="form.field.focus();" fires after the user starts
entering text into an input.

steps to reproduce problem:
1) go to http://amazon.com
2) quickly start typing into the 'search' input.
3) continue typing while onload fires
4) note that when onload fires, the 'search' input gets the focus and all text
is (correctly) selected
5) when you type the next letter, all your previous text is (correctry) replaced

for fast typers, this results in the subtle problem of submitting the form with
only part of what you typed, i.e., go to amazon to find Simpsons dvds, start
typing "Simpsons", onload happens, hit enter, actually search for "psons".

there are at least 2 solutions:
- forms should not allow input if they are referenced in body.onload events
until onload fires
- focus() should be defered if it's referenced in onload events and the user
manually set the focus before onload fires

FWIW, I could not get IE6 to demonstrate this problem.
More to the point, .focus() should not select the text if the field _already_
has focus.

Detecting that something is referenced is impossible, basically (you would need
to run the code in a sandbox to determine that, then run it again "for real",
which is not feasible, really).

This is a duplicate of the "focus() selects" issue.
Whiteboard: DUPEME

*** This bug has been marked as a duplicate of 178520 ***
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
Whiteboard: DUPEME
I'm reopening this as an enhancement because although, in a narrow way, bug
178520 will make the above case a non-issue, it doesn't address username/pw
combinations which will not only have a similar effect, but it will put your
password in the visible username field.  

one solution is to have a flag IsUserModified() on the form.  if it's true, make
body.onload="document.form.anything" do nothing.
Severity: normal → enhancement
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Summary: forms should not allow input if they are referenced in body onload events until onload fires → handle body.onload events messing with user input
Oh?  Really?  What about document.getElementById("something").focus()?  What
about calling .focus() from timeouts instead of from the handler directly?

What about input elements that are in different forms?  What about input
elements that are not even in a form?

Basically, I do not see how this "problem" can be "solved".
ouch.  ok I didn't mean to be simplistic or to imply that my suggestion took all
cases into account.

here's the "problem":  body.onload="mess with forms;" is common.  also common
are pages that have forms that are usable before onload fires.  these two things
make for bad usability.

here are a couple abstract "solution"s: 
- prevent interaction with forms until onload fires, if there is an onload event
- make onload do nothing if the target of the event is a node that the user has
interacted with
Priority: -- → P4
Target Milestone: --- → Future
Assignee: layout.form-controls → nobody
QA Contact: tpreston → layout.form-controls
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.