当我无法控制的第三方Javascript打开窗口时,有没有办法获取对inAppBrowser
窗口的引用?
目前正在inAppBrowser
中正确启动。我不知道如何/如果我可以引用它,以便我可以添加addEventListeners
。
这是他们打开弹出窗口的方式:
function launchPopupDirectly() {
if (popup && !popup.closed) {
return false;
}
var name = '';
var url = configuredOptions.domain + '/index.php?rm=box_select_view';
url += '&client_id=' + configuredOptions.clientId;
url += '&link_type=' + configuredOptions.linkType;
url += '&multiselect=' + configuredOptions.multiselect;
var specs = 'height=' + windowConfiguration.height + ',width='
+ windowConfiguration.width;
popup = window.open(url, name, specs);
detectPopupClose();
return true;
}
答案 0 :(得分:0)
在您的情况下,您可以将addEventListener
绑定到popup
。像这样
function launchPopupDirectly() {
if (popup && !popup.closed) {
return false;
}
var name = '';
var url = configuredOptions.domain + '/index.php?rm=box_select_view';
url += '&client_id=' + configuredOptions.clientId;
url += '&link_type=' + configuredOptions.linkType;
url += '&multiselect=' + configuredOptions.multiselect;
var specs = 'height=' + windowConfiguration.height + ',width='
+ windowConfiguration.width;
popup = window.open(url, name, specs);
//Modification here
popup.addEventListener('loadstart', function() {
alert('Browser loaded '+event.url);
});
detectPopupClose();
return true;
}
以下是您可以收听的事件列表:
参考:InAppBrowser文档http://cordova.apache.org/docs/en/3.3.0/cordova_inappbrowser_inappbrowser.md.html#addEventListener