2016-01-07 37 views
0

自從昨天以來,我一直在對抗科爾多瓦應用程序(iOS和Android)中的這個奇怪問題,所以我認爲是時候要求一點幫助。InAppBrowser.open with「_system」param在webview內部打開鏈接(僅適用於iOS)

我對 「deviceready」 事件運行下面的代碼:

document.addEventListener('deviceready', function() { 
    delete window.open; 

    $(document).on('mousedown','a', function(e) { 
     e.preventDefault(); 
     if (this.hostname !== window.location.hostname) { 
      const url = $(this).attr('href'); 
      cordova.InAppBrowser.open(url, '_system', 'location=yes'); 
     } 
    }); 
}, false); 

這是Android可以正常使用。在iOS中,它打開系統瀏覽器中的鏈接,當我回到我的應用程序時,它也在那裏打開。

回答

0

就找到了解決辦法。問題顯然是使用「mousedown」事件,切換到「點擊」做了這項工作。我還必須將e.preventDefault呼叫移動到if塊,否則內部鏈接將不起作用。

document.addEventListener('deviceready', function() { 
    delete window.open; 

    $(document).on('click','a', function(e) { 
     if (this.hostname !== window.location.hostname) { 
      e.preventDefault(); 
      const url = $(this).attr('href'); 
      cordova.InAppBrowser.open(url, '_system', 'location=yes'); 
     } 
    }); 
}, false); 
0

試試這個iOS和Android

window.open(urlValue, "_system", "location=yes"); 
相關問題