@@ -148,6 +148,7 @@ public class InAppBrowser extends CordovaPlugin {
148
148
private String footerColor = "" ;
149
149
private String beforeload = "" ;
150
150
private String [] allowedSchemes ;
151
+ private InAppBrowserClient currentClient ;
151
152
152
153
/**
153
154
* Executes the request and returns PluginResult.
@@ -264,7 +265,12 @@ else if (action.equals("loadAfterBeforeload")) {
264
265
@ SuppressLint ("NewApi" )
265
266
@ Override
266
267
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
+ }
268
274
inAppWebView .loadUrl (url );
269
275
}
270
276
});
@@ -964,8 +970,8 @@ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
964
970
}
965
971
966
972
});
967
- WebViewClient client = new InAppBrowserClient (thatWebView , edittext , beforeload );
968
- inAppWebView .setWebViewClient (client );
973
+ currentClient = new InAppBrowserClient (thatWebView , edittext , beforeload );
974
+ inAppWebView .setWebViewClient (currentClient );
969
975
WebSettings settings = inAppWebView .getSettings ();
970
976
settings .setJavaScriptEnabled (true );
971
977
settings .setJavaScriptCanOpenWindowsAutomatically (true );
@@ -1200,7 +1206,9 @@ public boolean shouldOverrideUrlLoading(String url, String method) {
1200
1206
boolean useBeforeload = false ;
1201
1207
String errorMessage = null ;
1202
1208
1203
- if (beforeload .equals ("yes" )
1209
+ if (beforeload .equals ("yes" ) && method == null ) {
1210
+ useBeforeload = true ;
1211
+ }else if (beforeload .equals ("yes" )
1204
1212
//TODO handle POST requests then this condition can be removed:
1205
1213
&& !method .equals ("POST" ))
1206
1214
{
0 commit comments