如何使phonegap window.location.href不启动Android上的Chrome [英] How to make phonegap window.location.href not launch Chrome on Android
问题描述
我有一个phonegap应用程序。在deviceReady我设置 window.location.href
到一些其他的URL。这在iOS 8.3上很好,但在Android 5.0.1我得到问,如果我想打开它在Chrome中,然后它是在Chrome而不是我的应用程序打开。
I've got a phonegap app. On deviceReady I set window.location.href
to some other URL. This works great on iOS 8.3 but on Android 5.0.1 I get asked if I want to open it in Chrome and then it's opened in Chrome instead of my app.
有办法获得在应用程序中打开的URL(如替换当前页面)。是的,我知道这不是最佳做法,一个单页的应用程序是更好的,blah blah blah,但这不适合我的用例在这一刻。
Is there way to get the URL to open in the app (as in replace the current page). Yes I know that's not best practice, a one page app is better, blah blah blah but that doesn't fit my use case at the moment.
推荐答案
如果你使用cordova 5与Android平台4.0.0,看看: https://github.com/apache/cordova-plugin-whitelist
If you are using cordova 5 with the android platform 4.0.0, have a look at: https://github.com/apache/cordova-plugin-whitelist
通过以下方式安装插件:
install the plugin via:
cordova外挂程式新增https://github.com/apache/cordova-plugin-whitelist.git --save
您需要添加:
< allow-navigation href =https: //example.com/*/>
因此,您将允许网页载入您的网页。
thanks to that, you will allow the webview to load your page.
这篇关于如何使phonegap window.location.href不启动Android上的Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!