0
votes

I try this code

document.addEventListener("deviceready", function(){
    console.log('test');
    var root = this;
    cb = window.plugins.childBrowser;

    if(cb != null) {
    console.log('test1');
    cb.onLocationChange = function(loc){ root.locChanged(loc); };
    cb.onClose = function(){root.onCloseBrowser(); };
    cb.onOpenExternal = function(){root.onOpenExternal(); };
    cb.showWebPage("http://assas.archus.fr/thumbs/pdf/methodo/sdsdfsd_sdf.pdf");
    }
}, false);

But no browser is opened is it normal ? all my console.log appear

Thanks

Edit:

code for 2.4.0

window.open('http://assas.archus.fr/thumbs/pdf/methodo/sdsdfsd_sdf.pdf', '_blank', 'location=yes');
2

2 Answers

1
votes

Android doesn't have a built in PDF Viewer as in iOS. So you need to open the PDF in a thrid party viewer like Google Document viewer as shown below:

cb.showWebPage(encodeURI("http://docs.google.com/viewer?url=http://assas.archus.fr/thumbs/pdf/methodo/sdsdfsd_sdf.pdf")

1
votes

Which version of PhoneGap are you using. From 2.3.0 version , you can use the InAppBrowser feature which ships with PhoneGap: http://docs.phonegap.com/en/2.4.0/cordova_inappbrowser_inappbrowser.md.html#InAppBrowser

This is much simpler to use than the ChildBrowser plugin.