8 Replies Latest reply on May 3, 2017 8:18 PM by Marc Autret

    Create popup warning that autocloses

    akiva_atwood

      Hi

       

      I'm trying to pop up a warning dialog for 2 seconds then have it close.

       

      The following code works:

       

      var w = new Window ("palette","test", [200, 200, 680, 325], {resizeable: false});   
      w.show();  
      alert("hi");
      w.close(); 
      

       

      but obviously doesn't autoclose

       

      var w = new Window ("palette","test", [200, 200, 680, 325], {resizeable: false});   
      w.show();  
        
      //delay(2);
      $.sleep(2000);
        
      w.close(); 
      
      
      function delay(prmSec){
        prmSec *= 1000;
        var eDate = null;
        var eMsec = 0;
        var sDate = new Date();
        var sMsec = sDate.getTime();
        do {
        eDate = new Date();
        eMsec = eDate.getTime();
        } while ((eMsec-sMsec)<prmSec);
        }
      

       

      using either delay or sleep the palette only shows up occasionally (every third run of the script...)

       

      1) any idea WHY it doesn't show up reliably?

       

      2) is there a better way to make a popup?

       

      thanks