func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if navigationAction.navigationType == WKNavigationType.linkActivated {
print("downloadable link")
// add alert here
decisionHandler(WKNavigationActionPolicy.cancel)
}else{
decisionHandler(WKNavigationActionPolicy.allow)
}
在这里(添加警报的位置)你可以像Safari一样添加警报,并根据需要使用。