decidePolicyForNavigationAction returns WKNavigationTypeOther for links clicked within iframe

When a WKWebView implements the WKNavigationDelegate protocol, clicking a link inside the webview gives back WKNavigationTypeLinkActivated as WKNavigationType in the decidePolicyForNavigationAction.

But clicking on a link inside an iframe gives back WKNavigationTypeOther, which makes it impossible to know if the url is requested on load or on click.

Context:

When a webview loads html (and embedded css, js, iframes, or XHR calls from JS ...), decidePolicyForNavigationAction gives back WKNavigationTypeOther as actionType , so I know content is loading and should be rendered in the webview. When a link is clicked, it gives back WKNavigationTypeLinkActivated so I know I need to show an in-app browser to show the content. This isn't the case with links clicked within an iframe (an <a> tag with href attribute); they return WKNavigationTypeOther

we also have this issue...

Solved by checking for navigationAction.targetFrame to be nil.

NavigationType will be "other" when the webview navigates with JS (window.open, window.location.href = ''). Checking for nil will catch JS navigation to new window.

decidePolicyForNavigationAction returns WKNavigationTypeOther for links clicked within iframe
 
 
Q