Button detection without navigation in WKWebView

I loaded the webpage in WKWebView . I want to determine when the user clicks this button.

 <div class="compacted-item"> <button class="btn btn-lg btn-primary deploy-button" data-ember-action="1361"> Deploy </button> </div> 

decidePolicyFor navigationAction does not start because it is not a navigation action.

I know how to add a js message handler to the web view content controller, but since I don't own the web page, how do I get it to send a message to intercept? For instance:

 window.webkit.messageHandlers.buttonClicked.postMessage(messageToPost); 

Or is there another way to detect clicks without navigation in WKWebView ?

+5
source share

Source: https://habr.com/ru/post/1257335/


All Articles