Last active
July 21, 2020 07:21
-
-
Save hsleedevelop/6f8c2f64dfbf75bcf169f7b7e8620523 to your computer and use it in GitHub Desktop.
WKWebView not opening links with target=“_blank”?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//My solution is to cancel the navigation and load the request with loadRequest: again. This will be come the similar //behavior like UIWebView which always open new window in the current frame. | |
// | |
//Implement the WKUIDelegate delegate and set it to _webview.uiDelegate. Then implement: | |
//https://stackoverflow.com/a/25853806/3374327 | |
- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures | |
{ | |
if (!navigationAction.targetFrame.isMainFrame) { | |
[webView loadRequest:navigationAction.request]; | |
} | |
return nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment