title: Opening two instances of InAppBrowser (_system and _blank) prevents events from triggering
body: <p>We’re currently developing an app with cordova and the InAppBrowser plugin. We're trying to spawn two different IAB instances at the same time. One with the _system browser and another with the _blank option. </p>
  
  <p>The problem we have is that once we open the instance of _system browser, it seems we lose the reference to the previous browser. For this reason, the close event never triggers on the _blank IAB after the _system browser is closed.</p>
  
  <p>This is how the actual code looks like.</p>
  
  <pre><code>// Opening iab main window
  var ref = window.open(global.chat_mediador, '_blank','location=no,toolbar=yes');
  
  var handleEvents =  function(event) {
  
      // Closing the iab window 
      if (event.url.match('#close')) {
          ref.close();
      }
  
      // Trigger custom event
      if (event.url.match('#openccard')) {
          window.open('https://www.test.example.url.com?customerID=' + event.customerId, '_system', 'location=yes');
      }
  
  }
  
  // InAppBrowser events
  
  // This events are duplicated because loadstop works on android and
  // loadstart works on ios.
  ref.addEventListener('loadstart', handleEvents, false);
  ref.addEventListener('loadstop', handleEvents, false);
  
  // Removing the dialog when we close the chat
  ref.addEventListener('exit', function(event) {
      generali.dialog.close();
  }, false);
  </code></pre>
  
  <p>As you can see we open the first url within the application with the _blank option. Then if in the child application a button is pressed we want to open an instance of a browser in the _system browser.</p>
  
  <p>We’ve tried (without luck) to:</p>
  
  <p><strong>Have a separate reference for the _system browser.</strong></p>
  
  <pre><code>window.open(global.url_ficha + customerId, '_system','location=no');
  var cardsRef = window.open(
      'https://www.test.example.url.com?customerID=' + customerId,
      '_system', 
      'location=yes'
  );         
  </code></pre>
  
  <p><strong>Trigger a custom event outside the reference of the _blank browser</strong></p>
  
  <pre><code> if (event.url.match('openccard')) {
       var customerId = event.url.split('openccard-')[1];
       var evt = document.createEvent("Event");
       evt.initEvent("openccard",true,true);
       evt.customerId = customerId;
       document.dispatchEvent(evt);
   }
  </code></pre>
  
  <p>Anyone has an idea of what's happening?</p>