diff --git a/Wikipedia/Code/SinglePageWebViewController.swift b/Wikipedia/Code/SinglePageWebViewController.swift index 5571c397f5c..d7a8af6ba7a 100644 --- a/Wikipedia/Code/SinglePageWebViewController.swift +++ b/Wikipedia/Code/SinglePageWebViewController.swift @@ -61,6 +61,7 @@ class SinglePageWebViewController: ViewController { private lazy var webView: WKWebView = { let webView = WKWebView(frame: UIScreen.main.bounds, configuration: webViewConfiguration) webView.navigationDelegate = self + webView.uiDelegate = self return webView }() @@ -274,3 +275,20 @@ extension SinglePageWebViewController: WKNavigationDelegate { fakeProgressController.finish() } } + +extension SinglePageWebViewController: WKUIDelegate { + func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) { + + let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert) + let action1 = UIAlertAction(title: CommonStrings.okTitle, style: .default) { _ in + completionHandler(true) + } + let action2 = UIAlertAction(title: CommonStrings.cancelActionTitle, style: .default) { _ in + completionHandler(false) + } + alertController.addAction(action1) + alertController.addAction(action2) + + present(alertController, animated: true) + } +}