PhoneGap: Open external link in default browser (outside the app)

前端 未结 16 1773
我在风中等你
我在风中等你 2020-12-09 15:36

I\'m trying to open links in Safari (on an iPhone) from a PhoneGap application. I\'m using PhoneGap version 3.1.0, and use PhoneGap Build, to build the application.

16条回答
  •  鱼传尺愫
    2020-12-09 16:30

    This is how i solved in Cordova/Phonegap 3.6.3

    Install the inappbroswer cordova plugin:

    cordova plugin add org.apache.cordova.inappbrowser
    

    I wanted to keep my phonegap app as similar as possible to a standard web page: I wanted that by having target="_blank" on a link, it would open in an external page.

    This is how i implemented it:

    $("a[target='_blank']").click(function(e){
      e.preventDefault();
      window.open($(e.currentTarget).attr('href'), '_system', '');
    });
    

    so all i have to do is use a link like the following

    Link
    

提交回复
热议问题