外部谷歌搜索链接在浏览器中打开

时间:2014-02-19 09:17:10

标签: ios cordova sencha-touch-2.1

我想在sencha touch hybrid ios app中打开像'https://www.google.co.in/#q=adam+scott'这样的谷歌搜索链接。我尝试使用var ref = window.open(url,'_ blank','location = yes');但它没有加载页面,如果我将_blank更改为_system,它正在加载页面,但没有显示完成按钮以移动到上一页。

如果某人已经做过,请告诉我。

2 个答案:

答案 0 :(得分:0)

我认为这就是你要找的东西:

navigator.app.loadUrl('https://www.google.co.in/#q=adam+scott',{openExternal:true});

答案 1 :(得分:0)

打开你的MainViewController.m类并在@end

之前添加这行代码
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)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"]){
        [[UIApplication sharedApplication] openURL:url];
        return NO;
    }
    else {
        return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
    }
}