// 1.拦截请求
NSString *urlString = [navigationAction.request.URL absoluteString];
// 2.跳转别的应用如系统浏览器(跨域跳转)、应用的web内跳转(不跨域跳转)
NSString *hostname = navigationAction.request.URL.host.lowercaseString;
if (navigationAction.navigationType == WKNavigationTypeLinkActivated) {//跳转别的应用如系统浏览器
// 对于跨域,需要手动跳转
[[UIApplication sharedApplication] openURL:navigationAction.request.URL];
// 不允许web内跳转
decisionHandler(WKNavigationActionPolicyCancel);
} else {//应用的web内跳转
decisionHandler (WKNavigationActionPolicyAllow);
}
return ;//不添加会崩溃