Skip to content

Can't load target="_blank" links on iOS #269

@aaronfg

Description

@aaronfg

WKWebView doesn't respect loading new windows (hrefs with target="_blank") like UIWebview did. So if I try to send a user to a page that opens one of its links in a new window, I get the "please disable popup blocker" toast notification.

Stops me from using this package for oauth sites that pop a new window up for the sign in process.

Seems there's an easy workaround in the WKUIDelegate to just capture those events and load them in the current view. I got this code from this stack overflow answer:

- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
{

  if (!navigationAction.targetFrame.isMainFrame) {

    [webView loadRequest:navigationAction.request];
  }

  return nil;
}

Not sure how much work that would be to add to the plugin, but if that could be done it would be great.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions