PhoneGap:在 Safari 中打开外部 URL [英] PhoneGap: Opening external URL's in Safari

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

问题描述

我刚刚升级到 PhoneGap 1.6.1,但无法再在 Safari 中打开外部 URL.

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

在此版本之前,我对 AppDelegate.m 进行了如下修补:

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];
    }
}

我注意到之前有人问过类似的问题:如何在 Safari 中打开外部链接而不是应用的 UIWebView?

I notice that a similar question has been asked before: How can I 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"到您的链接.

这对我有用.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆