How can I open an external link in Safari not the app's UIWebView?

后端 未结 10 1431
甜味超标
甜味超标 2020-11-28 10:47

I have a Phonegap (cordova) application where I want to load some external webpages within the phonegap WebView and I have other external webpages that I want to load in saf

10条回答
  •  生来不讨喜
    2020-11-28 10:55

    Just catch all links in your javascript that have target="_blank", and pass them to window.open with the '_system' param. This will work on both iOS and Android.

    $(document).on('click', 'a[target="_blank"]', function(ev) {
      var url;
    
      ev.preventDefault();
      url = $(this).attr('href');
      window.open(url, '_system');
    });
    

提交回复
热议问题