简体   繁体   English

在浏览器Cordova Android中打开URL

[英]Open URL in Browser Cordova Android

I have been trying to get inAppBrowser to load my url in an external browser on Android. 我一直试图让inAppBrowser在Android上的外部浏览器中加载我的网址。 I have set up inAppBrowser, however using _blank or _system leads to the same outcome. 我已经设置了inAppBrowser,但是使用_blank或_system会导致相同的结果。 The webpage loads inside the app instead of going out to a browser. 网页加载到应用程序内部,而不是浏览器。

HTML: HTML:

<a href="#" rel="external" id="link-forgotPass" >Forgot Password?</a>

JS: JS:

$('#link-forgotPass').bind('click', app.goToForgotPass);
goToForgotPass: function() {
    window.open('www.google.com', '_system', 'location=no');
    return false;
}  

XML: XML:

<feature name="InAppBrowser">
    <param name="android-package" value="org.apache.cordova.InAppBrowser" />
</feature>

What am I missing? 我想念什么? Do I need to bind inAppBrowser some how? 我需要如何绑定inAppBrowser吗? Thanks in advance. 提前致谢。

What version of Cordova do you have? 您有什么版本的Cordova? If it's >= 3.0 you can install the inAppBrowser plugin. 如果大于等于 3.0,则可以安装inAppBrowser插件。

And if its lower, the documentation says that you have to add: 而且如果文档较低,则说明您必须添加:

<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />

in app/res/xml/config.xml app/res/xml/config.xml

After trying to use InAppBrowser plugin with no avail I found the following snippet. 尝试无用InAppBrowser插件后,我发现了以下代码片段。 This seems to work in Android for Cordova 3.3. 这似乎可以在Android for Cordova 3.3中使用。 (I chose to bind the <a> element to a click event in order to execute the javascript code) (我选择将<a>元素绑定到click事件,以执行javascript代码)

Javascript: 使用Javascript:

 $('#link-forgotPass').bind('click', function() { navigator.app.loadUrl('your.url.here', {openExternal:true}); });

HTML: HTML:

<a href="#" rel="external" id="link-forgotPass" >Forgot Password?</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM