alert() not working in WKWebview evaluateJavaScript()

前端 未结 3 1233
执念已碎
执念已碎 2021-01-04 04:04

I don\'t why my question is marked as duplicate of this one, first I execute javascript code with evaluateJavaScript as the question title shows which it\'s

3条回答
  •  独厮守ぢ
    2021-01-04 04:14

    First of all you need to implement the required WKUIDelegate methods, in your case you need to implement:

    optional func webView(_ webView: WKWebView, 
        runJavaScriptAlertPanelWithMessage message: String, 
             initiatedByFrame frame: WKFrameInfo, 
            completionHandler: @escaping () -> Void)
    {
        // parameter **message** will hold your actual alert message.
    
        // Write Your Customised code to display the alert message
    }
    

提交回复
热议问题