Search code examples
cordovachildbrowser

childbrowser phonegap don't open window


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');

Solution

  • 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")