- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { NSString *url = [[navigationAction request].URL.absoluteString stringByRemovingPercentEncoding]; NSString* scheme = [navigationAction request].URL.scheme; if(![url containsString:@"https"] && ![url containsString:@"http"]){ if ([[UIDevice currentDevice].systemVersion floatValue] <= 10.0) { [[UIApplication sharedApplication] openURL:[navigationAction request].URL]; }else { [[UIApplication sharedApplication] openURL:[navigationAction request].URL options:@{} completionHandler:^(BOOL success) {}]; } //不允许跳转 decisionHandler(WKNavigationActionPolicyCancel); return ; } if ([scheme isEqualToString:self.jsScheme]) { self.onJsCallback(url.UTF8String); decisionHandler(WKNavigationActionPolicyCancel); return; } if (self.shouldStartLoading && url) { if (self.shouldStartLoading(url.UTF8String) ) decisionHandler(WKNavigationActionPolicyAllow); else decisionHandler(WKNavigationActionPolicyCancel); return; } decisionHandler(WKNavigationActionPolicyAllow); }