user2657362
user2657362

Reputation:

Open Link in Safari from loaded page in Webview

Im wondering how to open Link in Safari instead load in webview. i tried few ways,

    function openpage()
{
system.openURL ( "http://www.worldwildlife.org/gift-center/gifts/Species-Adoptions/Panda.aspx", "_blank" )
}

or window.open, target _blank nothing works. Any ideas? it could be html or JS/JQ, the point is to set button to open URL in safari insted of loading in uiwebview

Upvotes: 0

Views: 208

Answers (1)

user470763
user470763

Reputation:

If you have access to the app displaying the UIWebView this iOS snippet will direct all links in the UIWebView to open in Mobile Safari.

- (BOOL)webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
    if (inType == UIWebViewNavigationTypeLinkClicked) {
        [[UIApplication sharedApplication] openURL:[inRequest URL]];
        return NO;
    }

    return YES;
}

Upvotes: 1

Related Questions