Some test text!

menu
Open cordova or ionic links in external browserkeyboard_arrow_down

Open cordova or ionic links in external browser

First step is to install the "InAppBrowser" plugin. The name is a bit confusing but it will allow you to open links in the default browser when passing a certain parameter. Details about the plugin are here, but you'll just need to run the command

cordova plugin add org.apache.cordova.inappbrowser

Next we'll have to make a couple changes to your web app so that when window.open is called we'll inject the extra parameter '_system' which will open the link in the external browser. First look for a script tag that has the code $(document).bind("mobileinit")..., and inside that same script tag add the following code:

document.addEventListener('deviceready', function() {
    var oldOpen = window.open;
    window.open = function(target) {
        return oldOpen(target, '_system');
    };
});

The last change is to add the following line

<script src="../../cordova.js"></script>
<link rel="stylesheet" href="external/custom.css" />

This is the path to cordova.js if you followed the steps in WebViewer's cordova sample readme, there if you've changed the structure to fit your app then be sure that the URL correctly references cordova.js.

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.