我有一个工作,接受和批准的苹果,html5 phonegap网络应用程序,但我不能得到外部链接打开safari或地图应用程序。这个问题在android版本上也是一样的。
我猜,当点击/点击链接时,phonegap into浏览器会获取window.open事件,并将外部页面加载到当前窗口实例中,并且没有back键。
应用程序现在只会显示外部加载的页面,直到它退出并重新启动。
我已经阅读了大量关于这方面的评论和论坛。我已经遵循了我能找到的所有选项,但问题仍然存在。
谁能告诉我我哪里错了,因为我脱发的速度太快了…
Build使用phonegap.js和jquery与Phonegap3.1在线构建。我正在通过Jquery捕获外部链接,这一切都有效。
请在下面找到我正在使用的代码。
// capture external link click or tap?
$(document).on('click', 'a[data-rel="external"]', function(e){
e.preventDefault();
var targetURL = $(this).attr("href");
console.log('external link: '+targetURL);
var ref = window.open(targetURL, '_system', 'location=yes');
});我已经阅读了有关config.xml page link to phonegap的phonegap文档,这是我添加的内容。
<preference name="phonegap-version" value="3.1.0" />
<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
<plugin name="InAppBrowser" value="CDVInAppBrowser" />我还读到了有关Apple url-scheme name的内容,并在config.xml中使用了以下内容:
<gap:url-scheme name="com.canal-st.canal-st" role="None">
<scheme>mailto</scheme>
<scheme>tel</scheme>
<scheme>http</scheme>
</gap:url-scheme>我一定是漏掉了什么。最后,我调用了mobileinit bind,它在jquery.mobile之前被调用:
<script src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).bind("mobileinit", function(){
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
$.mobile.pushState = false;
console.log('in mobileinit');
});
</script>
<script src="js/jquery.mobile-1.3.1.min.js"></script>我知道这里有很多这样的问题,但没有一个解决方案有效,或者是新版本的phonegap造成了问题?
发布于 2014-08-30 03:37:40
您的系统应该使用'_self‘而不是window.open。示例:
$(document).on('click', 'a[data-rel="external"]', function(e){
e.preventDefault();
....
var ref = window.open(targetURL, '_self', 'location=yes');
});https://stackoverflow.com/questions/21558875
复制相似问题