2014-02-25 30 views
2

有沒有一種方法來獲得對第三方Javascript,我沒有控制權打開該窗口時引用inAppBrowser窗口?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

在你的情況,你可以綁定addEventListenerpopup。像這樣

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; 
} 

這裏是事件的列表,你可以傾聽:

  • loadstart:當InAppBrowser開始加載URL事件觸發。
  • loadstop:事件在InAppBrowser完成加載URL時觸發。
  • loaderror:事件在InAppBrowser加載URL時遇到錯誤時觸發。
  • exit:事件在InAppBrowser窗口關閉時觸發。

參考:InAppBrowser文檔http://cordova.apache.org/docs/en/3.3.0/cordova_inappbrowser_inappbrowser.md.html#addEventListener

+0

我應該使人們更清楚,我沒有在功能控制launchPopupDirectly()。我將這個功能包含在內,以顯示第三方如何打開窗口。 – user1594257

+0

您可以通過直接插入「popup」來控制IAP。當你說你不能控制這個功能時,你是什麼意思?你是否在HTML文檔的另一層上操作?通過iframe或其他東西? –

+0

我有類似的情況。我們有一個混合應用程序,它使用認證服務注入它用來啓動應用程序瀏覽器的代碼,所以我們沒有選擇加入事件監聽器的選項。但是,似乎沒有辦法做到這一點。 –

相關問題