JsBeforeUnloadEvent

class JsBeforeUnloadEvent(val view: WebView, val url: String, val message: String, val result: JsResult) : SyncHandlerEvent

Notify the host application that the web page wants to confirm navigation from JavaScript onbeforeunload. The default behavior if this method returns false or is not overridden is to show a dialog containing the message and suspend JavaScript execution until the dialog is dismissed. The default dialog will continue the navigation if the user confirms the navigation, and will stop the navigation if the user wants to stay on the current page. To show a custom dialog, the app should return true from this method, in which case the default dialog will not be shown and JavaScript execution will be suspended. When the custom dialog is dismissed, the app should call JsResult.confirm() to continue the navigation or, JsResult.cancel() to stay on the current page. To suppress the dialog and allow JavaScript execution to continue, call JsResult.confirm() or JsResult.cancel() immediately and then return true. Note that if the WebChromeClient is set to be null, or if WebChromeClient is not set at all, the default dialog will be suppressed and the navigation will be resumed immediately. Note that the default dialog does not inherit the android.view.Display.FLAG_SECURE flag from the parent window.

Call SyncHandlerEvent.shouldHandle if the request is handled or ignored, otherwise WebView needs to show the default dialog.

Constructors

Link copied to clipboard
constructor(view: WebView, url: String, message: String, result: JsResult)

Properties

Link copied to clipboard
Link copied to clipboard

Message to be displayed in the window.

Link copied to clipboard

A JsResult used to send the user's response to javascript.

Link copied to clipboard
val url: String

The url of the page requesting the dialog.

Link copied to clipboard

The WebView that initiated the callback.

Functions

Link copied to clipboard