UIWebview不允许加载 跳转到其他页面
#pragma mark =========== 拦截webview
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString *urlStr = [request.URL absoluteString];
//拦截链接跳转到货源圈的动态详情
if([urlStr containsString:@"kdpc//WxShare//"])
{
//跳转到你想跳转的页面 我这边做的是地址判断
NSString *st =[urlStr URLDecodedString];
NSLog(@"跳转到你想跳转的页面----------%@",st);
return NO; //返回NO,此页面的链接点击不会继续执行,只会执行跳转到你想跳转的页面
}
return YES;
}
WKWebView 不允许加载 跳转到其他页面
#pragma mark ==== 不让加载 不允许跳转
- (void)webView:(WKWebView*)webView decidePolicyForNavigationResponse:(WKNavigationResponse*)navigationResponse decisionHandler:(void(^)(WKNavigationResponsePolicy))decisionHandler
{
NSString *newUrl=webView.URL.absoluteString ;
//https://dev.kdpche.com/StoreManage/kdpc//CodeScan
if([newUrlcontainsString:@"kdpc//WxShare//"]) {
//跳转到你想跳转的页面 我这边做的是地址判断
decisionHandler(WKNavigationResponsePolicyCancel);
}
else
{
decisionHandler(WKNavigationResponsePolicyAllow);
}
}