lifeontime opened a new issue, #965:
URL: https://github.com/apache/cordova-plugin-inappbrowser/issues/965
# Bug Report
## Problem
I use an IAB instance to load my site into a Cordova webview in a _blank
window so I can catch calls to window.open and replace them with
cordova.InAppBrowser.open. This works fine the first time, however when the new
window loads (also _blank) the first IAB instance seemingly gets destroyed
(after inspecting, it is actually set to about:blank).
### What is expected to happen?
The first IAB instance should load the second and still exist when the
second instance is closed.
### What does actually happen?
The first IAB instance loads the second but seemingly gets destroyed in the
process.
## Information
<!-- Include all relevant information that might help understand and
reproduce the problem -->
### Command or Code
<!-- What command or code is needed to reproduce the problem? -->
```
document.addEventListener('deviceready', function() {
var url = 'https://example.com/login/';
newWindowRef = cordova.InAppBrowser.open( url, '_blank',
'location=no,toolbar=no' );
listenForMessage( newWindowRef );
newWindowRef.addEventListener( 'loadstop',
assignWindowOpenFunction );
}, false);
function assignWindowOpenFunction() {
newWindowRef.executeScript({
code: "\
function openWinFromApp( url, target, options ) {\
var obj = {\
url: url,\
target: target,\
options: options\
};\
var objStr = JSON.stringify(obj);\
webkit.messageHandlers.cordova_iab.postMessage(objStr);\
}\
window.open = openWinFromApp;"
},
function( result ) {
}
);
}
function listenForMessage( win ) {
win.addEventListener( 'message', function( params ) {
var newWin = cordova.InAppBrowser.open( params.data.url,
'_blank', 'toolbar=yes,location=yes' );
listenForMessage( newWin );
} );
}
```
### Environment, Platform, Device
<!-- In what environment, on what platform or on which device are you
experiencing the issue? -->
OS = Windows 10, Platform = Android (testing on Samsung Galaxy A12)
### Version information
<!--
What are relevant versions you are using?
For example:
Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
Other Frameworks: Ionic Framework and CLI version
Operating System, Android Studio, Xcode etc.
-->
Cordova CLI v 11.0.0, IAB 5
## Checklist
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]