This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { | |
if ((navigationType == UIWebViewNavigationTypeLinkClicked) && | |
([[[request URL] absoluteString] hasPrefix:@"https://www.google.com"])) | |
{ | |
[[UIApplication sharedApplication] openURL:request.URL]; | |
return NO; | |
} | |
return YES; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { | |
if ((navigationType == UIWebViewNavigationTypeLinkClicked) && ([[url absoluteString] hasSuffix:@"?openExternal=1"] )) | |
{ | |
[[UIApplication sharedApplication] openURL:url]; | |
return NO; | |
} | |
return YES; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { | |
NSURL *url = [request URL]; | |
if ( ([url fragment] != NULL) && ([[url fragment] rangeOfString:@"openExternal=true"].location != NSNotFound) ) | |
{ | |
if ([[UIApplication sharedApplication] canOpenURL:url]) { | |
[[UIApplication sharedApplication] openURL:url]; | |
return NO; | |
} | |
} | |
return YES; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* turn all target = _blanks into whitelisted urls */ | |
$(document).on("click", function (event) { | |
if (event.target.target === "_blank" && event.target.href.indexOf("#openExternal=true") === -1) { | |
event.target.href = event.target.href + "#openExternal=true"; | |
} | |
}); |