在Safari中打开外部URL

在Safari中打开外部URL

本文介绍了PhoneGap:在Safari中打开外部URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚升级到PhoneGap 1.6.1,我无法再在Safari中打开外部网址。

I've just upgraded to PhoneGap 1.6.1 and I can no longer get external URL's to open in Safari.

在此版本之前,我修补了AppDelegate。如下:

Prior to this version I had patched AppDelegate.m as follows:

- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSURL *url = [request URL];
    if ([[url scheme] isEqualToString:@"http"]) {
        [[UIApplication sharedApplication] openURL:url];
        return NO;
    } else {
        return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
    }
}

我注意到之前已经提出过类似的问题:

I notice that a similar question has been asked before:phonegap: open an external link in Safari not the app's UIWebView

但是看起来我喜欢这个答案不再适用于1.6.1版本。

But it looks to me like this answer no longer works on version 1.6.1.

我也试过在Cordova.plist中设置OpenAllWhitelistURLsInWebView,但是这两个设置都没有给我Safari。

I've also tried setting OpenAllWhitelistURLsInWebView in Cordova.plist but neither setting gives me Safari.

提前感谢。

推荐答案

升级到Cordova 1.6.1后出现同样的问题。

Had the same problem after upgrading to Cordova 1.6.1.

尝试添加
target =_ blank
到您的链接。

Try addingtarget="_blank"to your links.

这篇关于PhoneGap:在Safari中打开外部URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 01:32