androidOnJsBeforeUnload property
Event fired when the client should display a dialog to confirm navigation away from the current page.
This is the result of the onbeforeunload
javascript event.
If JsBeforeUnloadResponse.handledByClient is true
, WebView will assume that the client will handle the confirm dialog.
If JsBeforeUnloadResponse.handledByClient is false
, a default value of true
will be returned to javascript to accept navigation away from the current page.
The default behavior is to return false
.
Setting the JsBeforeUnloadResponse.action to JsBeforeUnloadResponseAction.CONFIRM will navigate away from the current page,
JsBeforeUnloadResponseAction.CANCEL will cancel the navigation.
jsBeforeUnloadRequest
contains the message to be displayed in the alert dialog and the of the page requesting the dialog.
NOTE: available only on Android.
Official Android API: https://developer.android.com/reference/android/webkit/WebChromeClient#onJsBeforeUnload(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)
Implementation
@override
final Future<JsBeforeUnloadResponse?> Function(
InAppWebViewController controller,
JsBeforeUnloadRequest jsBeforeUnloadRequest)? androidOnJsBeforeUnload;