@@ -148,6 +148,7 @@ public class InAppBrowser extends CordovaPlugin {
148148 private String footerColor = "" ;
149149 private String beforeload = "" ;
150150 private String [] allowedSchemes ;
151+ private InAppBrowserClient currentClient ;
151152
152153 /**
153154 * Executes the request and returns PluginResult.
@@ -264,7 +265,12 @@ else if (action.equals("loadAfterBeforeload")) {
264265 @ SuppressLint ("NewApi" )
265266 @ Override
266267 public void run () {
267- ((InAppBrowserClient )inAppWebView .getWebViewClient ()).waitForBeforeload = false ;
268+ if (android .os .Build .VERSION .SDK_INT < android .os .Build .VERSION_CODES .O ) {
269+ currentClient .waitForBeforeload = false ;
270+ inAppWebView .setWebViewClient (currentClient );
271+ } else {
272+ ((InAppBrowserClient )inAppWebView .getWebViewClient ()).waitForBeforeload = false ;
273+ }
268274 inAppWebView .loadUrl (url );
269275 }
270276 });
@@ -964,8 +970,8 @@ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
964970 }
965971
966972 });
967- WebViewClient client = new InAppBrowserClient (thatWebView , edittext , beforeload );
968- inAppWebView .setWebViewClient (client );
973+ currentClient = new InAppBrowserClient (thatWebView , edittext , beforeload );
974+ inAppWebView .setWebViewClient (currentClient );
969975 WebSettings settings = inAppWebView .getSettings ();
970976 settings .setJavaScriptEnabled (true );
971977 settings .setJavaScriptCanOpenWindowsAutomatically (true );
@@ -1200,7 +1206,9 @@ public boolean shouldOverrideUrlLoading(String url, String method) {
12001206 boolean useBeforeload = false ;
12011207 String errorMessage = null ;
12021208
1203- if (beforeload .equals ("yes" )
1209+ if (beforeload .equals ("yes" ) && method == null ) {
1210+ useBeforeload = true ;
1211+ }else if (beforeload .equals ("yes" )
12041212 //TODO handle POST requests then this condition can be removed:
12051213 && !method .equals ("POST" ))
12061214 {
0 commit comments