Keystrokes ignored when checking opener?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • quest313
    New Member
    • Mar 2008
    • 5

    Keystrokes ignored when checking opener?

    When typing in text fields in my web page I noticed random keystrokes are
    occasionally skipped (ignored). You sometimes have to type a while before it happens.
    I traced this down to a function we are using to check if the opener is still
    open. Included is a simplified version of my problem. Any insight would be
    appreciated.

    I am testing with IE 7.0.5730.11 on Windows XP I don't see this behavior in IE 6.

    <!-- Opener File -->

    [HTML]<html>
    <head>
    <title>Exampl e</title>
    <script>
    function initForm()
    {
    window.open("ch eckopener.html" , "test");
    }
    </script>
    </head>
    <body onLoad="initFor m()">
    </body>
    </body>
    </html>[/HTML]

    <!-- File Checking opener with textbox -->
    [HTML]<html>
    <head>
    <title>Exampl e</title>
    <script>
    function checkOpener()
    {
    if (opener == null || opener.closed)
    {
    self.close();
    return;
    }
    setTimeout("che ckOpener()", 5); // value is set low to illustrate problem
    }
    function initForm()
    {
    checkOpener();
    }
    </script>
    </head>
    <body onLoad="initFor m()">
    <center>
    <input type="text" name="txtfield" ></input>
    </center>
    </body>
    </body>
    </html>[/HTML]
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    How often is the opener checked in the real application?

    Comment

    • quest313
      New Member
      • Mar 2008
      • 5

      #3
      It checks every 50 ms, but the I still see the problem as high 500ms and 1000ms frequently.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by quest313
        When typing in text fields in my web page I noticed random keystrokes are
        occasionally skipped (ignored). You sometimes have to type a while before it happens.
        Around how long? I can't seem to reproduce the problem.

        btw, you have two closing body tags in the popup window code.

        Comment

        • quest313
          New Member
          • Mar 2008
          • 5

          #5
          I'd say around 5% of the characters are skipped but its random. When the setTimeout is this small, its not hard to see it. I do only see this behavior in IE 7.0, so if you have a different browser it may not happen.

          Sorry about the duplicate <body> tags, I typed up the example quickly for demo purposes.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Now I see the problem.

            It seems like a bug. Is it necessary to check the opener, or can you not close the popup window from the parent window instead?

            Comment

            • quest313
              New Member
              • Mar 2008
              • 5

              #7
              Closing from the parent is a solution, but we have a large site and this would require a larger amount of changes.

              Thanks for your help. As far as I know if it is indeed a bug, there's not much we can do besides hope it is fixed soon.

              We have tried referring to opener as window.opener, using setInverval instead of setTimeout and other ideas but they all have the same problem.

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Unless someone else comes up with a solution/fix, I guess you'll have to wait till IE8 comes out and then hope that it's fixed in that release.

                Comment

                Working...