InAppBrowser Not Working with Phonegap Build

156 views Asked by At

I am trying to use the InAppBrowser plugin with Phonegap Build but when I click on my link, the web page does not open in the InAppBrowser. I can remove the plugin from the config.xml and it does not make a difference. I have used the following plugin in my config.xml file.

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

Below is my code to open the InAppBrowser in my js file. I am using window.open to call the InAppBrowser and using google as a test. Does anyone know what I am doing incorrectly? Any help is greatly appreciated.

$(document).ready(function() {

    var listHtml = "";

    var url = "http://example.com/mypage.php"
    $.post(url, function(response) {
            var json = $.parseJSON(response);

            $.each(json, function(key, value) {
                listHtml += "<li><a href='#' onclick=window.open('http://www.google.com','_blank','location=yes,toolbar=yes')><img class='ui-circle ui-mini ui-padding' src='" + value.image + "'><h2>" + value.name + "</h2><p><strong>" + value.title + "</strong></p><p><strong>" + value.date + "</strong></p></li>";

                $("#history").html(listHtml);
                $('ul').listview('refresh');

            }); //end list
1

There are 1 answers

0
Mark Veenstra On

I think you need to bind window.open to cordova.InAppBrowser.open, see documentation here.

$(document).ready(function(){
    window.open = cordova.InAppBrowser.open; // BIND

    var listHtml = "";

    var url = "http://example.com/mypage.php"
    $.post(url, function(response){
        var json = $.parseJSON(response);

        $.each(json, function(key, value){
            listHtml += "<li><a href='#' onclick=window.open('http://www.google.com','_blank','location=yes,toolbar=yes')><img class='ui-circle ui-mini ui-padding' src='"+ value.image +"'><h2>" + value.name +  "</h2><p><strong>"+ value.title + "</strong></p><p><strong>" + value.date +"</strong></p></li>";

            $("#history").html(listHtml);
            $('ul').listview('refresh');

        });
    });
});