United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4984794 Invisible applet steals focus from HTML form field (MSIE, Sun plug-in only)
JDK-4984794 : Invisible applet steals focus from HTML form field (MSIE, Sun plug-in only)

Details
Type:
Bug
Submit Date:
2004-01-28
Status:
Closed
Updated Date:
2010-05-28
Project Name:
JDK
Resolved Date:
2008-04-14
Component:
deploy
OS:
windows_nt,windows_xp,windows_2000
Sub-Component:
plugin
CPU:
x86
Priority:
P3
Resolution:
Cannot Reproduce
Affected Versions:
1.4.1,1.4.2,1.4.2_04,5.0,6
Fixed Versions:
6u10

Related Reports
Backport:
Backport:
Duplicate:
Duplicate:
Duplicate:
Duplicate:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
Name: gm110360			Date: 01/28/2004


FULL PRODUCT VERSION :
java version "1.4.2_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)

FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

EXTRA RELEVANT SYSTEM CONFIGURATION :
We've seen this happening for quite some time, so the specific version of IE probably isn't critical. We've also seen it in previous versions of the Java plug-in, including 1.3.x.



A DESCRIPTION OF THE PROBLEM :
*** I submitted this bug 6 weeks ago (on Sept 11, 2003), and it was given an internal review ID of 207044. The confirmation email I received said there was a three week backlog. I still haven't heard the disposition of this report. Thank you. ***

The attached files show how an invisible applet "steals" focus from a form element. We have an applet on a page that performs some processing when called from JavaScript, but we don't want the applet itself to be visible on the page. Fortunately, we can disable its display by using style="display:none". However, when this applet is on the page, it grabs focus away from the HTML form field. It seems reasonable to us that this would be okay if the applet is visible, but if the applet isn't even being displayed, it shouldn't happen.

Enclosed:
TestApplet.java - a very simple applet.
good.html - An HTML file with a single form field. An onload script sets the focus to the form field. As soon as the page comes up, you can start typing, and the characters go into the form field. This is good. bad.html - Same as good.html, with the addition of an invisible applet. When it loads, you can see the cursor flash momentarily in the form field, but then if you start typing your keystrokes are lost. This is bad.

Note that the problem does not occur when using the Microsoft VM (5.0.0.3810), nor does it occur when using Netscape 7.1. Therefore, it appears to be an interaction between MSIE 6 and the Sun Plug-in.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See description above. Just open bad.html in MSIE 6. When the page comes up, start typing. The characters go nowhere.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
When the page comes up, the characters you type should go into the form field.
ACTUAL -
When the page comes up, the characters you type go nowhere.


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
---TestApplet.java---
import java.applet.*;

public class TestApplet extends Applet
{
	public TestApplet ()
	{
		System.err.println( "TestApplet" );
	}

	public void init()
	{
		System.err.println( "TestApplet init" );
	}
	public void destroy()
	{
		System.err.println( "TestApplet destroy" );
	}
}

---

---good.html---
<html>
<body onload="document.TestForm.TestField.focus()">
<form name="TestForm">
Field: <input name="TestField" size="40">
</form>
</body>
</html>

---


---bad.html---
<html>
<body onload="document.TestForm.TestField.focus()">
<applet code="TestApplet.class" width="2" height="2" style="display:none"></applet> <form name="TestForm">
Field: <input name="TestField" size="40">
</form>
</body>
</html>

---

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
There are a couple of options here:
(1) Use Netscape instead of MSIE.
(2) In the onload code, use setTimeout() to reset the focus after a few hundred milliseconds. This gives the applet time to steal the focus, then we can steal it back.
(Incident Review ID: 218432) 
======================================================================
###@###.### 10/13/04 10:09 GMT

                                    

Comments
EVALUATION

Talked to Deva. It is very complicated issue.

1. Applet over aggressively grabs focus.

2. Asynchronized focus handle between applet and plugin control window.


###@###.### 2004-01-29

Since setDefaultFocus() method, which is the place to grab focus not matter browser grants focus to applet or not, was developed by AWT team, it is better to have AWT team to do further investigation and fix.

One thing I would like to point out. display:none is not the only case causes applet not getting default focus. There is potential unlimited way to not make applet as default focus component, by html tag attributes, tabIndex or javascript. So, fix should not base on special cases.

Re-assign to AWT team.


###@###.### 2004-02-09
                                     
2004-02-09
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
mustang


                                     
2004-10-02
EVALUATION

Besides the work done in update release and the fix for 6234219, there are no plans to implement another beheavior in Mustang.  This still remains an important bug and we'll look into the alternative solutions for it in Dolphin.
                                     
2005-09-27
EVALUATION

This bug has been fixed in the new plugin.  Verified that this bug is not reproducible with 6u10 b21 in IE.
                                     
2008-04-14



Hardware and Software, Engineered to Work Together