title: Javascript -- wait for user interaction without freezing the browser
body: <p>I don't speak English very well.</p>
  
  <p>My company has developed a web application for internet explorer that very strenuously uses the function <code>showModalDialog</code> and waits for the result.</p>
  
  <p>We are planning to extend the use of the application to other browsers (Firefox, Chrome), and I need to replace "<code>showModalDialog</code> logic" with a logic that will work well on all browsers.</p>
  
  <p>I originally tried using an <code>ajaxcontroltoolkit</code> <code>modalpopup</code> with an <code>iframe</code> inside.</p>
  
  <p>My problem is that, after I have showed the <code>modalpopup</code>, I cannot wait for the user to close the popup window without freezing the web interface.</p>
  
  <pre><code>function OpenDialog() {
      var result = window.showModalDialog("page1.html", "input_parameter", "width:100px; height:100px");
  
      //When the popup went closed
      alert("result: " + result);
  }
  
  //Override showModalDialog function for compatibility with other browser
  function myShowModalDialog(url, pars, options) {
  
      //show a jquery modalpopup or ajaxcontroltoolkit modalpopup with an iframe ....
      iframe.src = url;
  
      //I need to wait here until the modal popup closed
      //HOW?
  
      //get the value from popup
      var res = ???????;
  
      return res;
  }
  
  window.showModalDialog = myShowModalDialog;
  </code></pre>
  
  <p>I cannot change the logic for every page in the webapp.</p>
  
  <p>I searched for a method to override the <code>showModalDialog</code> function and recreate the same logic (wait until the popup is closed and get the result that the popup provides for the caller).</p>
  
  <p>Any ideas? Thanks to all</p>