Dave Voyles
Dave Voyles

Reputation: 4605

location bar not appearing in InAppBrowser for iOS, Cordova

I'm trying to load an external page in my iOS app, using Cordova. The page loads fine, but I can't get the location bar to display.

    <script>
    // Wait for device API libraries to load
    document.addEventListener("deviceready", onDeviceReady, false);

    // device APIs are available
    function onDeviceReady() {
        $("#btn").click(function(){
            var ref = window.open('http://apache.org', '_blank', 'location=yes', 'toolbar=yes');
            ref.addEventListener('loadstart', function(event) { alert('start: ' + event.url); });
            ref.addEventListener('loadstop',  function(event) { alert('stop: '  + event.url); });
            ref.addEventListener('loaderror', function(event) { alert('error: ' + event.message); });
            ref.addEventListener('exit',      function(event) { alert(            event.type); });
        });
    }

</script>

<button id="btn">trigger</button>

I can't figure out why the location bar won't load.

I'm appending a navbar and footer to each of my locally stored pages as well, but appending to any container with "data-role=page", and that works well, but obviously it won't work in this instance. I need to find another to do so with external pages.

I'm really only looking for the location bar and buttons so that I can navigate back to my app when the user closes the page.

Any help would be appreciated. I'm using Cordova 3.3.0

Upvotes: 3

Views: 1519

Answers (1)

kontur
kontur

Reputation: 5217

I believe the option parameter in the window.open call needs to be a comma-separated string, not strings separated by commas.

This:

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

should be:

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

As per the documentation for 3.3.0:

The options string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive. ...

Upvotes: 1

Related Questions