windows - cordova mac 在 safari 中打开 URL

标签 windows cordova safari hyperlink

我正在使用以下 https://github.com/apache/incubator-cordova-mac制作 mac os x 应用程序,但似乎我无法打开 _blank 链接。如果有人知道那该多好。

答案 1) - 没有用

我把它放在 WebViewDelegate.m 中 -

UIWebViewNavigationType < is the error

- (BOOL) webView:(WebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    //return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
    NSURL *url = [request URL];

    // Intercept the external http requests and forward to Safari.app
    // Otherwise forward to the PhoneGap WebView
    if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"] || [[url scheme] isEqualToString:@"itms-apps"]) {
        [[UIApplication sharedApplication] openURL:url];
        return NO;
    }
    else {
        return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
    }
}

最佳答案

我认为 _blank 更改是最近的更改,尚未在 iOS 中实现。我目前在 AppDelegate.m 中使用这段本地代码在 Safari 中打开外部 URL

- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    //return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
    NSURL *url = [request URL];

    // Intercept the external http requests and forward to Safari.app
    // Otherwise forward to the PhoneGap WebView
    if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"] || [[url scheme] isEqualToString:@"itms-apps"]) {
        [[UIApplication sharedApplication] openURL:url];
        return NO;
    }
    else {
        return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
    }
}

关于windows - cordova mac 在 safari 中打开 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10945905/

相关文章:

windows - BATCH - 向函数添加计数器(for/loop)

ios - 在 Cordova 中使用相机后,iOS 收到内存警告

Javascript 全局(主体)点击事件注册在 Safari 中不起作用

windows - Erlang 应用程序在 Windows 服务器上启动

RubyMine - 没有为项目配置 Ruby 解释器

c# - 为 Windows 服务打开防火墙

Cordova 生成发布 apk 而不是 aab

android - 创建 Android AVD 时如何设置系统镜像(路径?)?

jQuery/移动 Safari 错误?

CSS 的 JQuery 属性更改在 Chrome 中不起作用