Search code examples
ioscordovainappbrowser

Open local html with InAppbrowser


I've been looking for ways to open a html local levels, Local I mean that the html is inside the www folder of the application of phonegap, with inappbrowser.

var about = window.open("About.html", "_blank", "location=yes");

This is the line of code with which I intend to do this, but apparently does not work, if someone could help me I would be very grateful.


Solution

  • The code that you have written is correct. it is opening page in inappbrowser.

    Now the thing is you have to make sure that you call it after device is ready.

    Also check you are using 2.x version of cordova framework. and still if you getting issue with the inappbrowser please provide some more information.

    var app = {
        // Application Constructor
        initialize: function() {
            this.bindEvents();
        },
        // Bind Event Listeners
        //
        // Bind any events that are required on startup. Common events are:
        // 'load', 'deviceready', 'offline', and 'online'.
        bindEvents: function() {
                document.addEventListener('deviceready', this.onDeviceReady, false);
        },
        // deviceready Event Handler
        //
        // The scope of 'this' is the event. In order to call the 'receivedEvent'
        // function, we must explicity call 'app.receivedEvent(...);'
        onDeviceReady: function() {
            app.receivedEvent('deviceready');
        },
        // Update DOM on a Received Event
        receivedEvent: function(id) {
            var about = window.open("about.html", "_blank", "location=yes");
            console.log('Received Event: ' + id);
        }
    };