PhoneGap Build: how to open external url in device browser on Android?

后端 未结 6 1415
难免孤独
难免孤独 2020-12-03 07:25

External URL\'s don\'t open in the system\'s browser in my PhoneGap Android application. I\'m using PhoneGap Build 2.3.0.

According to the Cordova documentation I u

6条回答
  •  猫巷女王i
    2020-12-03 08:12

    This worked for me. Phonegap 3.1.0.

    html code:

    Google it
    

    or

    
    

    Javascript (with jQuery+cordova):

    $("#ext-link").on("click"), function() {
        if (typeof navigator !== "undefined" && navigator.app) {
            // Mobile device.
            navigator.app.loadUrl('http://www.google.com/', {openExternal: true});
        } else {
            // Possible web browser
            window.open("http://www.google.com/", "_blank");
        }
    });
    

    Hope that helps.

提交回复
热议问题