赞
踩
static const NSString *CompanyFirstDomainByWeChatRegister = @"com.cn";
// 在收到响应后,决定是否跳转
- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler{
NSLog(@"在收到响应后:%@",navigationResponse.response.URL.absoluteString);
//允许跳转
decisionHandler(WKNavigationResponsePolicyAllow);
//不允许跳转
//decisionHandler(WKNavigationResponsePolicyCancel);
}
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
// 如果是跳转一个新页面
if (navigationAction.targetFrame == nil) {
NSString *str = [navigationAction.request.URL absoluteString];;
if ([str rangeOfString:@"outjbtmwv"].location != NSNotFound) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}else{
[webView loadRequest:navigationAction.request];
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。