0
をAUTOCLOSE、私はwkWebViewウィンドウを閉じるには - 私はwkWebViewでポップアップをクリックすると
- (nullable WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{
if (!navigationAction.targetFrame.isMainFrame) {
//[webView loadRequest:navigationAction.request];
[self showInternalWeb:navigationAction.request.URL.absoluteString];
}
return nil;
}
を経由して、そのアクションを取得し、別のコントローラ内のリンクを表示します。
ウィンドウを閉じたときにコントローラを自動的に終了したいと思います。私のラップトップブラウザでは、新しいウィンドウのボタンを押すとコントローラが自動的に閉じられます。私はどのようにこの機能をコードするのだろうかと思います。
私が呼び出し試してみました:
[userContentController addScriptMessageHandler:self name:@"window.close()"];
[self.webView evaluateJavaScript:@"window.close()" completionHandler:^(id _Nullable obj, NSError * _Nullable error) {
NSLog(@"suces");
}];
は、これは、通常webViewDidCloseを呼び出しますが、ウィンドウは空白になっていないとき。