Keystrokes ignored when checking opener?

Discussion in 'JavaScript' started by quest313, Mar 10, 2008.

  1. #1
    When typing in text fields in my web page I noticed random keystrokes are
    occasionally skipped. 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.

    Opener File
    
    <html>
    <head>
    <title>Example</title>
    <script>
    function initForm()
    {
      window.open("checkopener.html", "test");
    }
    </script>
    </head>
    <body onLoad="initForm()">
    </body>
    </body>
    </html>
    
    HTML:
    File Checking opener with textbox
    
    <html>
    <head>
    <title>Example</title>
    
    
    <script>
    
    function checkOpener()
    {
    
      if (opener == null || opener.closed)
      {	
    	self.close();
    	return;
      }
     
      setTimeout("checkOpener()", 5); // value is set low to illustrate problem
    }
    
    function initForm()
    {
      checkOpener();
    }
    </script>
    </head>
    <body onLoad="initForm()">
    <center>
    <input type="text" name="txtfield"></input>
    </center>
    </body>
    </body>
    </html>
    
    HTML:

     
    quest313, Mar 10, 2008 IP