2013-03-02 61 views
2

我不知道爲什麼,但是當我做了以下的PhoneGap /科爾多瓦InAppBrowser沒有推出

<img id="buttons" src="https://qikout.com/apppics/MerchantPromo.png" style="margin:1% auto; width:99% !important;" onclick="openextlink('https://qikout.com');"/> 

function openextlink(url) 
{ 
var ref = window.open(url, '_blank', 'location=no'); 
//window.plugins.childBrowser.showWebPage(url, { showLocationBar: true }); 
} 

它工作正常。但是當我想在另一個函數中運行openextlink時,它不會打開窗口,而是加載頁面,但不會顯示給用戶。

例如,

function scan(){ 

    window.plugins.barcodeScanner.scan(function(result) { 
      if(result.format != "QR_CODE") 
      { 
      alert("That is not a valid google Tag"); 
      } 
      else 
      { 
       n = result.text.split(".com/"); 
       loadpet(); 

        //alert("We got a barcode\n" + 
        //  "Result: " + result.text + "\n" + 
        //  "Format: " + result.format + "\n" + 
        //  "Cancelled: " + result.cancelled); 

      } 
     }, function(error) { 
      alert("Scanning failed: " + error); 
     } 
    ); 

} 

function loadpet(){ 
    $("#buttons").trigger("click"); 
    var link = "http://www.google.com/" + n[1]; 
    openextlink(link); 
} 

它的工作原理通過

<div onclick="scan();" class="menu-right"></div> 

基本上,它會掃描精細,它得到的結果它會將結果向loadpet功能,甚至將其發送到openextlink功能但不彈出瀏覽器。

+0

n [1]裏面的值是什麼? – Whizkid747 2013-03-02 15:42:59

回答

0

您的window.open代碼看起來是正確的(根據InAppBrowser的工作方式與Cordova 3.0相同)。

您能確認以下所有條目嗎?

  • InAppBrowser插件在/#myapp#/platforms/#platform#/www/cordova_plugins.js文件中有條目嗎?
  • 的InAppBrowser插件文件夾是在/#MYAPP#/平臺/#平臺#/插件/
  • 的相關SRC文件InAppBrowser是在平臺的文件夾,以及(例如IOS插件的src文件:/#MYAPP #/ platforms /#platform#/#appname#/ Plugins /)

此外,如果以上所有都已確認, )行到你的inappbrowser.js文件的末尾,以確認它確實正在加載(假設你已經設置了調試控制檯並可以查看輸出)。

相關問題