From 9f4b72982abf50ddc54a34bd3748b6a3aad3be57 Mon Sep 17 00:00:00 2001 From: Dave Alden Date: Sun, 10 Feb 2019 17:06:35 +0000 Subject: [PATCH] GH-417: Handle non-default target attribute values (e.g. target=on links in WKWebView implementation on iOS (#418) --- src/ios/CDVWKInAppBrowser.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index 121223f..7deb6d0 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -573,7 +573,14 @@ static CDVWKInAppBrowser* instance = nil; } if(shouldStart){ - decisionHandler(WKNavigationActionPolicyAllow); + // Fix GH-417: Handle non-default target attribute + // Based on https://stackoverflow.com/a/25853806/777265 + if (!navigationAction.targetFrame.isMainFrame){ + [theWebView loadRequest:navigationAction.request]; + decisionHandler(WKNavigationActionPolicyCancel); + }else{ + decisionHandler(WKNavigationActionPolicyAllow); + } }else{ decisionHandler(WKNavigationActionPolicyCancel); }