feat(WKwebview): Allow _target links to be opened up in the same way as UIWebView. (#270)

Fixes #139
This commit is contained in:
Benjos Antony 2019-02-01 09:18:02 +08:00 committed by Thibault Malbranche
parent bf3f790358
commit 6643a8e38d
1 changed files with 11 additions and 0 deletions

View File

@ -73,6 +73,17 @@ static NSString *const MessageHanderName = @"ReactNative";
return self;
}
/**
* See https://stackoverflow.com/questions/25713069/why-is-wkwebview-not-opening-links-with-target-blank/25853806#25853806 for details.
*/
- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
{
if (!navigationAction.targetFrame.isMainFrame) {
[webView loadRequest:navigationAction.request];
}
return nil;
}
- (void)didMoveToWindow
{
if (self.window != nil && _webView == nil) {