Phonegap 3.0 InAppBrowser - Provides no way for user to close

隐身守侯 提交于 2019-12-04 06:52:15

Your syntax looks okay, but give these code snippets a try:

Pure JavaScript:

var ref = window.open('http://cnn.com', '_blank', 'location=yes,toolbar=yes');

HTML + JavaScript:

<a href="#" onclick="var ref = window.open('http://cnn.com', '_blank', 'location=yes,toolbar=yes');">CNN Link</a>

Also, check that you have correctly installed the InAppBrowser plugin (PhoneGap/Cordova 3.0+ need it to be installed separately via the command line). Your config.xml file looks correct, but just make sure that the rest of the plugin is installed properly.

You can use the following commands to list all the installed plugins in your project...

Using Cordova: cordova plugins

Using PhoneGap: phonegap local plugin list

You can also just go to your Desktop, navigate to the 'plugins' folder within your project and check that there is a folder named 'org.apache.cordova.inappbrowser' or 'org.apache.cordova.core.inappbrowser' inside.

To install the InAppBrowser plugin (if necessary)...

Using Cordova: cordova plugin add org.apache.cordova.inappbrowser

Using PhoneGap: phonegap local plugin add org.apache.cordova.inappbrowser

From your description, it sounds like your page is opening within the app's webview, instead of the InAppBrowser window. This is the behaviour you would normally get if you used '_self' instead of '_blank'. Hopefully something here will help fix it.

If you are using PhoneGap Build then you need to use different syntax i.e. (see plugin info):

<gap:plugin name="org.apache.cordova.inappbrowser" />

See also PGB plugin repository. It seem to be up-to-date now. You can see a simple test application for a working version.

Note that this might not be working if you are building yourself (locally on your computer). Use instructions by wicketyjarjar if you are building locally.

Shri Guru

The inAppBrowser did not work with Phonegap 3.0.0, and had to change this in config.xml to make it work on both ios and Android :

<plugin name="inAppBrowser">

to

<gap:plugin name="org.apache.cordova.inappbrowser" />

Also if you would want to include emailcomposer use the below line in config.xml

<gap:plugin name="de.appplant.cordova.plugin.email-composer" />

and in the Javascript file add the below lines:

var ops = {
    callback: function (result) {
        navigator.notification.alert(result);
    },
    subject: "Look at this photo",
    body: "Take a look at <b>this</b>:",
    toRecipients: ["example@email.com", "johndoe@email.org"],
    ccRecipients: [],
    bccRecipients: [],
    isHTML: true,
    attachments: ["_complete_path/image.png"]
}

function mail(name, url) {
    window.plugin.email.open({
        to: [],
        cc: [],
        bcc: [],
        subject: name,
        body: url,
        isHtml: true
    });
}

I had the same problem. In my case it was caused by forgetting to include the cordova.js script.

<script type="text/javascript" src="cordova.js"></script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!