简体   繁体   English

PhoneGap:InAppBrowser

[英]PhoneGap: InAppBrowser

I have installed the plugin: https://github.com/apache/cordova-plugin-inappbrowser I have followed their installation directions:我已经安装了插件: https : //github.com/apache/cordova-plugin-inappbrowser我遵循了他们的安装说明:

Installation

cordova plugin add cordova-plugin-inappbrowser
If you want all page loads in your app to go through the InAppBrowser, 
you can simply hook window.open during initialization. For example:

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    window.open = cordova.InAppBrowser.open;
}

I have added this to my config.xml:我已将此添加到我的 config.xml 中:

<gap:plugin name="cordova-plugin-inappbrowser" source="npm" version="1.0.1" />
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>

This is my code to use the above:这是我使用上述内容的代码:

    <a href="javascript:testOne();">Test 1</a>
    <br>
    <a href="javascript:testTwo();">Test 2</a>

<script type="text/javascript">
function testOne() {
    var ref = cordova.InAppBrowser.open('http://google.com', '_blank', 'location=yes');
}
function testTwo() {
    var ref = cordova.InAppBrowser.open('http://google.com', '_system', 'location=yes');
}
</script>

To no avail, when I click these links (on Android), nothing happens.无济于事,当我单击这些链接(在 Android 上)时,没有任何反应。 Why?为什么?

Have you tried你有没有尝试过

window.open('http://example.com', '_blank');

without the document ready listener you have added.没有您添加的文档就绪侦听器。

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

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