![](/img/trans.png)
[英]InAppbrowser window.open plugin for Cordova 3.5 not working
[英]InAppBrowser plugin for Cordova/Phonegap — window.open not opening links in default browser
我正在嘗試將InApBrowser PhoneGap插件添加到我的網絡應用程序中,以便在移動默認瀏覽器中打開鏈接。
webapp使用AngularJS和IonicFramework進行編程。
我知道有非常相似的問題,但我嘗試過的解決方案到目前為止都沒有。
因此,當我創建apk文件並在我的Android手機設備上運行時,有些東西無法正常工作。 順便說一下,我通過https://build.phonegap.com/構建了apk文件 。
在我的索引文件中,我有這個功能:
<!-- JQuery library -->
<script src="lib/jquery-2.1.3.min.js"></script>
<script type="text/javascript">
$(document).on('click', '.external', function (e) {
e.preventDefault();
window.open(e.target.href, '_system');
});
</script>
我的一個問題是使用這段代碼 :
<p>
<a id="btn-noticias" class="button button-block button-stable external"
ng-href="{{noticia.uri}}">
Ver noticia en la web
</a>
</p>
鏈接在appview中打開,而不是在默認瀏覽器中打開。
在這段代碼中 :
<a class="item lista-item examen external" ng-repeat="examen in filteredExSept"
ng-href="{{examen.URI}}"
ng-hide="errorConexionExSept || examenesSeptiembre.length==0 || filteredExSept.length==0">
<div class="tituloExamen" ng-bind-html="examen.asignatura"></div>
</a>
應用程序甚至沒有打開鏈接,不在瀏覽器中,在appview中沒有...只是沒有打開鏈接。
在這里你可以看到config.xml文件:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<widget id="com.ionicframework.myapp377389"
version="0.0.1"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:gap="http://phonegap.com/ns/1.0">
<name>SmartCULM</name>
<description>
An application...
</description>
<author email="gps_e25@googlegroups.com">
Daniel García Páez
</author>
<content src="index.html"/>
<access origin="*"/>
<!--
If you do not want any permissions to be added to your app, add the
following tag to your config.xml; you will still have the INTERNET
permission on your app, which PhoneGap requires.
-->
<preference name="permissions" value="none"/>
<!-- Core plugins -->
<gap:plugin name="org.apache.cordova.inappbrowser" />
<gap:plugin name="org.apache.cordova.device" />
<!-- Define app icon for each platform. -->
<icon src="img/apk_icon.png" />
</widget>
那么,誰知道我做錯了什么? 使用InAppBrowser插件還是使用angularjs代碼?
您可以在此處訪問我的整個項目。
更新我已在PhoneGap文檔中找到config.xml中訪問標記(也稱為白名單)的下一個信息:
在Android上,如果某個域列入白名單,則鏈接將接管整個網絡視圖。 如果不是,它將在瀏覽器中打開。
所以,據我所知,如果我想在默認瀏覽器中打開我的所有鏈接( http://culm.unizar.es/ *和https://culm.unizar.es/ *)我必須避免包含它們在白名單中。 我怎么做的? 我有點困惑......我已經嘗試但不確定是否可以。
這是我使用的代碼,由以下幾個來源編譯:
var externalLinkToOpen = $(this).attr("href");
if (app.isPhoneGap()) {
if (device.platform === 'Android') {
navigator.app.loadUrl(externalLinkToOpen, { openExternal: true });
} else {
window.open(externalLinkToOpen, '_system');
}
} else {
window.open(externalLinkToOpen, "_blank");
}
“app.isPhoneGap”只是檢查設備是否==未定義以查看是否作為網站運行(幾乎所有我構建的網站都是我的應用程序)。 而且,是的,我在項目中也有InApp瀏覽器插件。
在config.xml中:
<access origin="*" />
<allow-intent href="*" />
<allow-navigation href="*" />
請更新它是否有效<我與android有同樣的問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.