I'm trying to have a WKWebView
in my Mac app (Objective-C) open links with _target='_blank'
externally in the default web browser (i.e. using [[NSWorkspace sharedWorkspace] openURL:aURL]
).
I've read two similar questions (1, 2) but the solutions found do not work for me on OS X. For 1, webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures
gives a nil request URL; and 2 does not work for some pages with dynamic content (e.g. Inbox by Google / inbox.google.com).
Are there any good or unorthodox/hack-y solutions to the problem for OS X? Seeing as decidePolicyForNavigationAction
provides a nil
URL for the navigationAction
's request.URL
, is there another way of getting clicked links to open them in the user's browser?