2012-07-29 71 views
0

由於phonegap 2 window.plugins不再可用,但childBrowser仍然依賴於此。 如何在phonegap 2項目中調用childBrowser插件?帶電話2.0的兒童瀏覽器

這在1.9工作正常:

cb = window.plugins.childBrowser; 
+0

解決方法?使用jQuery。 – 2012-07-29 21:45:07

回答

1

首先從這裏https://github.com/phonegap/phonegap-plugins/tree/8848e8dd7f0d93810eec49fb1124f6389c963b68/Android/ChildBrowser

使用下載最新的兒童瀏覽器2.0.0 版本

插件創建對象window.plugins.childBrowser。要使用,請撥打以下其中一種可用方法:

/** 
    * Display a new browser with the specified URL. 
    * This method loads up a new web view in a dialog. 
    * 
    * @param url   The url to load 
    * @param options  An object that specifies additional options 
    */ 
    showWebPage(url, [options]) 
Sample use: 

window.plugins.childBrowser.showWebPage("http://www.google.com", { showLocationBar: true }); 
    /** 
    * Close the browser. 
    */ 
    close() { 
Sample use: 

window.plugins.childBrowser.close(); 
    /** 
    * A user supplied call back which is run when the browser is closed. 
    */ 
    onClose() 
Sample use: 

window.plugins.childBrowser.onClose(); 
    /** 
    * A user supplied call back which is run when the browser location changes. 
    * The method is called with the new location of the browser. 
    */ 
    onLocationChange(location) 
Sample use: 

window.plugins.childBrowser.onLocationChange(location); 
    /** 
    * Display a new browser with the specified URL. 
    * 
    * NOTE: If usePhoneGap is set, only trusted PhoneGap URLs should be loaded, 
    *  since any PhoneGap API can be called by the loaded HTML page. 
    * 
    * @param url   The url to load 
    * @param usePhoneGap Load url in PhoneGap webview [optional] - Default: false 
    */ 

    openExternal(url, [usePhoneGap]) 
Sample use: 

window.plugins.childBrowser.openExternal("http://www.google.com");