[英]Cordova will not open iframe target links in system browser (or at all)
[英]Cordova 3.5 - Android open links in the mobile system browser not working at all
我知道這已經被問過很多次了。 但是對於我的一生,我似乎無法使其與所有這些解決方案一起使用。
我正在使用cordova 3.5 + jquery mobile(用於設計)+一些js插件。
這些是我嘗試過並做過的事情:
navigator.app.loadUrl("http://google.com", {openExternal : true});
<a onclick="navigator.app.loadUrl('https://google.com/', { openExternal:true });">Link</a>
在這里,我得到了未找到的錯誤導航器,並且該鏈接僅在應用程序內保持打開狀態。
然后我從這里跟隨一些想法:
<access origin="http://alunny.github.com" browserOnly="true" />
在這種情況下,當我使用cordova進行構建時,browserOnly才被更改,然后顯然沒有發生更改。
然后,我發現使用JS函數的另一種方法是:
<script type="text/javascript">
$('a[target=_blank]').on('click', function(e) {
e.preventDefault();
window.open($(this).attr('href'), '_system');
return false;
});
</script>
這里什么也沒發生。
我應該提到其中大多數是去年的答案,而沒有提及Cordova 3.5.0-0.2.6 。
因此,我將針對該特定版本啟動該線程,非常感謝您的幫助。 我正在測試的手機是運行Android 4.4.4的MotoG。
sagar提供的鏈接中接受的答案就是解決方案。我在運行android 4.4的motog中嘗試過,並且工作正常。添加了window.open(' http: //www.google.de','_system'); 並將inapp瀏覽器插件安裝在項目目錄中。
我的科爾多瓦版本是3.4,但我認為這不應該有所作為
發布了我根據您所需的示例創建的示例測試項目https://gist.github.com/rahulinaction/f5d347ea9c74a941273e
這是一個簡單的演示:
<h1 onclick="window.open('yourWebsiteAddress')">HELLO THERE EVERYONE</h1>
另外,您還需要添加cordova插件: org.apache.cordova.inappbrowser
使用此鏈接 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.