You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/02/11 08:54:04 UTC

[GitHub] FarhadG opened a new issue #420: postMessage example from documentation doesn't work

FarhadG opened a new issue #420: postMessage example from documentation doesn't work
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/420
 
 
   I need the ability to be able for an `inappbrowser` instance to communicate with the parent (the `opener`). Given that there is no `opener` object with the `inappbrowser`, I've looked through repo's documentation and tests, and I cannot reproduce the `postMessage` API to communicate between an `inappbrowser` instance and the main Cordova application (parent).
   
   Here's a simple example taken from the documentation/test within this repo:
   
   ```
   const ref = cordova.InAppBrowser.open('http://www.google.com', '_blank');
   
   ref.addEventListener('loadstop', function(evt) {
     console.log('loadstop has been fired');
     ref.executeScript({
       code: `(() => {
         var message = "TESTING!!!";
         webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify(message));
       })()`
     });
   });
   
   ref.addEventListener('message', (...args) => {
     console.log('MESSAGE RECEIVED FROM IN_APP_BROWSER', ...args);
   });
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org