Post

Replies

Boosts

Views

Activity

Open javascript popup in WKWebView?
I have a WKWebView in my app which opens a page where there is a button that uses javascript to open another page with window.open(). Now it's seems that webView(navigationAction) is never called when tapping this button. I have managed to get target="_blank" links to open, but I don't understand how I can get window.open() to work? I have added a uiDelegate to create popup windows like this: public class WKWebVC: UIViewController { 	... 	override public func viewDidLoad() { 		super.viewDidLoad() 		webView.navigationDelegate = self 		webView.uiDelegate = self 		webView.configuration.preferences.javaScriptEnabled = true    webView.configuration.preferences.javaScriptCanOpenWindowsAutomatically = true 	... and then the extension for WKWebVC: extension WKWebVC: WKUIDelegate {   private func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? {     debugPrint("(👉🏽👉🏽👉🏽 createWebViewWith")     popupWebView = WKWebView(frame: view.bounds, configuration: configuration)     popupWebView!.autoresizingMask = [.flexibleWidth, .flexibleHeight]     popupWebView!.navigationDelegate = self     popupWebView!.uiDelegate = self     view.addSubview(popupWebView!)     return popupWebView!   }   private func webViewDidClose(_ webView: WKWebView) {     if webView == popupWebView {       popupWebView?.removeFromSuperview()       popupWebView = nil     }   } } But createWebViewWith is never called either...
2
2
11k
Oct ’20