Cordova (PhoneGap) and iFrames

cordova, ios5

Solution

I have a sample application here which does open the Vimeo video inside the app but opens the other urls in Safari.

I changed the below function in MainViewController.m

- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSURL *url = [request URL];
    NSString *host = [request.URL host];

    if(host != NULL || host != nil){
        if ([host rangeOfString:@"vimeo.co"].location != NSNotFound) {
            return YES;
        }else{
            if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
                [[UIApplication sharedApplication] openURL:url];
                return NO;
            }
            else {
                return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
            }
        }
    }

    return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}

Problem

It seems everyone knows about the dumb little but in PhoneGap that doesn't allow you to have iFrames in your application. There are a number of fixes out there but they are either for legacy versions of PhoneGap, don't work or cause other issues. Here is what I have tried so far: OpenAllWhitelistURLsInWebView http://craigpfau.com/2012/02/phonegap-ios-uiwebview-and-safari-app-links/ - How can I open an external link in Safari not the app's UIWebView? Nothing seems to work. Here is what I'm trying to accomplish: - Video embeds from vimeo (iframe) stay in app, externalhosts: vimeo.com a.vimeocdn.com b.vimeocdn.com - All other links go out to safari Here are my app details: ios 5.1.1 | Cordova 1.7.0 | JqueryMobile | Jquery 1.7.1

Original source

Related problems