Closed
Bug 7133
Opened 25 years ago
Closed 25 years ago
onFocus event does not work if we try to give focus to element using JS method focus()
Categories
(Core :: DOM: UI Events & Focus Handling, defect, P3)
Tracking
()
VERIFIED
FIXED
People
(Reporter: desale, Assigned: rods)
References
Details
(Whiteboard: [PDT+]I have a fix)
onFocus event does not work if we try to give focus to element using JavaScript
method focus().
focus() method seems working fine since I can see blinking curson in element,
and onFocus event also works fine if I try to give focus using mouse. This event
just does not take place when I try to give focus using method focus().
Product: seamonkey [Apprunner/ Viewer]
Build: 05-25-09.
Steps to reproduce bug:
1] Please copy the code I'm providing. Save as HTML file and open this file in
viewer as well as apprunner.
2] You'll see one Testing text box, which is supposed to get default focus from
javascript method focus().
3] You'll see one more text box called Result Text Box, which prints result of
onFocus event.
4] Now try to click in Testing Text Box.
Expected Results:
As soon as page loads "Result Text Box" should show that "Testing Box Got
Focus" since we are giving focus to testing text box through javascript.
Actual Results:
"Result Text Box" does not show anything. But we can see blinking cursor in
testing text box.
Conclusion:
This means onFocus event does not work if we try to give focus using focus()
method.
CODE:
<html>
<head>
<title>Test Page</title>
</head>
<SCRIPT LANGUAGE="JavaScript1.1">
function report(text)
{
var value=document.workform.result.value;
var msg= value+ " " +text;
document.workform.result.value=msg;
}
</SCRIPT>
<body >
<form name="workform">
Testing Text Box:<INPUT TYPE=text name="testing1" size=15
onFocus="report('Testing Box Got Focus');">
Result Text Box:<INPUT TYPE=text name="result" size=60><br><br>
<SCRIPT LANGUAGE="JavaScript1.1">
document.workform.testing1.focus();
</SCRIPT>
<input type="reset" value="Reset">
</form>
</body>
</html>
END OF CODE.
Reporter | ||
Updated•25 years ago
|
QA Contact: 3847 → 4616
Reporter | ||
Comment 1•25 years ago
|
||
Changing QA contact to myself.
Assignee | ||
Updated•25 years ago
|
Assignee: joki → rods
Assignee | ||
Updated•25 years ago
|
Status: NEW → ASSIGNED
Whiteboard: [MAKINGTEST] compact@cam.org → I have a fix
Assignee | ||
Comment 2•25 years ago
|
||
A couple of things. First it is invalid to have script embedded in the HTML.
Since the DOM isn't fully built it is invalid to execute script on it.
If I put the .focus() in a onload handler it will now work.
Waiting to check in.
Assignee | ||
Updated•25 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 3•25 years ago
|
||
This will work for all form controls but the textfield and textarea. That is a
separate bug. marking fixed as in a general case.
Assignee | ||
Updated•25 years ago
|
Status: RESOLVED → REOPENED
Assignee | ||
Comment 4•25 years ago
|
||
This needs to be reopened because I had to back out my change because it didn't
work on Linux.
Reporter | ||
Updated•25 years ago
|
Resolution: FIXED → ---
Reporter | ||
Comment 5•25 years ago
|
||
Clearing Resolution.
Putting on [PDT]+ radar.
Whiteboard: I have a fix → [PDT+]I have a fix
Assignee | ||
Updated•25 years ago
|
Status: REOPENED → RESOLVED
Closed: 25 years ago → 25 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 7•25 years ago
|
||
Fixed, checked in, tested.
Reporter | ||
Updated•25 years ago
|
Status: RESOLVED → VERIFIED
Reporter | ||
Comment 8•25 years ago
|
||
Working fine. Tested with 10-19-09 builds.
Updated•6 years ago
|
Component: Event Handling → User events and focus handling
You need to log in
before you can comment on or make changes to this bug.
Description
•