Shazron's Cordova (aka PhoneGap) Blog

at Adobe Systems Inc.

Posts Tagged ‘white-list

InAppBrowser (based on ChildBrowser) in Cordova 2.3.0

with 97 comments

The inclusion of the InAppBrowser in iOS and Android will be new for Cordova 2.3.0. You can play with the InAppBrowser today if you download the latest code and help us test.

The InAppBrowser is a built-in web browser for your app that has an API that follows web standards. It follows the window.open API, except for a new window target that we introduced: “_system“. Read our simple specification.

Does this mean the ChildBrowser is going away? Not really. These two plugins can co-exist, and ChildBrowser has added features that are not present in the InAppBrowser, particularly events. [UPDATE: see below]InAppBrowser also has no dependencies on a .xib or external images, so it is easy to integrate for upgrades.

What’s also new with the InAppBrowser implementation for iOS is, the white-list is not applied application wide anymore, the white-list will only apply for the main Cordova UIWebView only. Now you can load non-white-listed URLs into the InAppBrowser and the ChildBrowser.

There are several enhancements for plugins related to this new white-list exception functionality as well – please see issue CB-1889. The enhancements should land before the final 2.3.0 is released.

Please help us test by downloading the latest code or RC and giving this new feature a spin!

[Update Nov 28 2012]: The InAppBrowser on iOS has support for events now (Android in progress). You can listen to the ‘loadstart‘, ‘loadstop‘ and ‘exit‘ events. The callback function is passed an event object that has two properties: type, and url. You will need to grab the latest code and javascript (create a new project).

Example usage:

var ref = window.open('http://google.com', '_blank');
ref.addEventListener('loadstart', function(event) { alert(event.type + ' - ' + event.url); } );
ref.addEventListener('loadstop', function(event) { alert(event.type + ' - ' + event.url); } );
ref.addEventListener('exit', function(event) { alert(event.type); } );

// also, you can do ref.removeEventListener('loadstart', myfunc) .. etc

[Update Nov 30 2012]: Changes for InAppBrowser events for Android are in cordova-android now.

[Update Jan 7 2013]: If you have a multi-page app, and you use InAppBrowser, and you use iOS 6, you must use iframe bridge mode. More details here.

Written by shazron

November 21, 2012 at 8:06 pm

Follow

Get every new post delivered to your Inbox.

Join 1,412 other followers

%d bloggers like this: