Search code examples
androidcordovahybrid-mobile-app

Phonegap: Open a URL in default browser


How to open a URL in default browser in android?

I've tried <a href="#" onclick="window.open('http://www.google.com', '_system');">www.google.com</a> but it opens up in the same app window, but I want it to open up in a default browser's window.


Solution

  • Make sure you added the in app browser plugin. Please check it in your config.xml file(It is in your res/xml/config.xml) the following line is present.

    <plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
    

    Like the following you can add the plugin:

    phonegap local plugin add your plugin url here
    

    And also chances may be there if you are using phonegap build the in app browser is open instead of default system browser(even though you are using _system).

    For more details refer this Stack overflow answer