我想在我的网页应用程序中添加InAppBrowser PhoneGap插件,以便在移动默认浏览器中打开链接。
网页应用程序使用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>
链接在应用视图中打开,而不是默认浏览器中打开。
并且在这段代码中:
<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>
这个应用程序甚至不能打开链接,无论是在浏览器中还是在应用程序视图中都无法打开链接。
在这里你可以看到我的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上,如果一个域名被列入白名单,链接将占据整个Web视图。如果没有,它将在浏览器中打开。
因此,我理解,如果要在默认浏览器中打开所有我的链接(http://culm.unizar.es/*和https://culm.unizar.es/*),我必须避免将它们包含在白名单中。如何实现?我有点困惑……我已经尝试过,但不确定是否正确。