1、WKWebView处理新开窗口的请求处理,贴一个实例代码
-(WKWebView*)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{
NSString *url = [navigationAction.request.URL absoluteString];
_htmlVCShouldShowToast = NO;
APPWKWebViewController *htmlVC = [[WKWebView alloc] initWithFrame:self.webView.frame configuration:configuration];
NSMutableURLRequest *request = navigationAction.request;
[request setHTTPMethod:@"POST"];
[_payInfoStr dataUsingEncoding:NSUTF8StringEncoding];
[request setValue:[_payInfoStr encodingWithString]forHTTPHeaderField:@"mfscabc"];
// [request setHTTPBody:[_payInfoStr dataUsingEncoding:NSUTF8StringEncoding]];
// WKWebView加载请求
[webView loadRequest:request];
if(_htmlVCHaveShowToast){
[APPShowMessage hiddenToastOnWindow];
}
// [self leftBarButtonItemIsClick];
return htmlVC;
}
网友评论