我正在使用以下 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/