Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4984794

Invisible applet steals focus from HTML form field (MSIE, Sun plug-in only)

XMLWordPrintable

    • x86
    • windows_nt, windows_2000, windows_xp

        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

              mafishersunw Margarita Fisher (Inactive)
              gmanwanisunw Girish Manwani (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: