D Schwarz: firefox setInterval top.close

Beitrag lesen

Hallo Leute!

Ich habe ein javascript, dass ein Popup öffnet. Dieses Popup soll einen HTMLrequest nach AJAX-Manier starten. Wenn der HTMLrequest fehlschlägt, soll das Popup sich schließen. Wichtig ist, dass setinterval benutzt wird. Mit dem IE läuft es. Mit Firefox 2 funktioniert es nur, wenn ich auf das Popup nach 1000 ms klicke. Was mache ich falsch bzw. ist das ein Bug?

CODE:
Erstes HTML-File (dieses muss man aufrufen):
<html>
  <body>
  <script language="javascript">
    window.open('popup.html','popup','width=450,height=175,status=no,toolbar=no,menubar=no,resizable=yes,location=no');
  </script>
  </body>
</html>

Zweites HTML-File (popup):
<html>
  <script type="text/javascript">
    function ajaxFunction(){
     var ajaxRequest;

try{
      // Opera 8.0+, Firefox, Safari
      ajaxRequest = new XMLHttpRequest();
     } catch (e){
      // Internet Explorer Browsers
      try{
       ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
       try{
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e){
        //browsers all not support, rare case
        alert("Your browser broke!");
        return false;
       }
      }

}
     return ajaxRequest;
    }

function showData(htmlcode) {
      var htmlRequest;
      htmlRequest = ajaxFunction();
     if (htmlRequest==null){ // If it cannot create a new Xmlhttp object.
      alert ("Browser does not support HTTP Request");
      return;
     }

htmlRequest.onreadystatechange = function(){
      if(htmlRequest.readyState == 4){
        if (htmlRequest.status!=200) {
          setInterval("top.close()", 10);
          } else {
         document.getElementById("shoutarea").innerHTML = htmlRequest.responseText;
          }
      }
     }

htmlRequest.open("GET", htmlcode, true);
      htmlRequest.send(null);
    }

</script>

<body>
  <script type="text/javascript">
    setInterval("showData('diesesFileExistiertNicht.html')", 1000);
  </script>
  </body>
</html>