Search code examples
cordovabuttonpluginswebhybrid-mobile-app

How to open webpage in app


Im building an app and within this app I want it so when the user clicks a link to open a webpage. I want the webpage to open in-application... so in the app. How would I go about doing this? I know this requires a cordova plugin to do this. I don't want the webpage to open in a browser.


Solution

  • You have to use inAppBrowser plugin https://github.com/apache/cordova-plugin-inappbrowser

    Then you can use this code to open the web inside the inAppBrowser and the user won't leave your app:

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

    On a button

    <input type="button" value="Open"
        onClick="window.open('http://apache.org', '_blank', 'location=yes');">