Skip to content

Commit

Permalink
feat(WKwebview): Allow _target links to be opened up in the same way …
Browse files Browse the repository at this point in the history
…as UIWebView. (#270)

Fixes #139
  • Loading branch information
noproblem23 committed Feb 1, 2019
1 parent 9e472a4 commit 29f686b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ios/RNCWKWebView.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ - (instancetype)initWithFrame:(CGRect)frame
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) {
Expand Down

0 comments on commit 29f686b

Please sign in to comment.