Click or drag to resize

IJsDialogsBeforeUnloadHandler Property

Gets or sets a handler that is used when the web page is about to be unloaded.

Namespace:  DotNetBrowser.Browser.Dialogs
Assembly:  DotNetBrowser (in DotNetBrowser.dll) Version: 2.22.1
Syntax
C#
IHandler<BeforeUnloadParameters, BeforeUnloadResponse> BeforeUnloadHandler { get; set; }

Property Value

Type: IHandlerBeforeUnloadParameters, BeforeUnloadResponse
Exceptions
ExceptionCondition
ObjectDisposedExceptionThe IBrowser has already been disposed.
ConnectionClosedExceptionThe connection to the Chromium engine is closed.
Remarks

Some web pages may override the window.onbeforeunload JavaScript function, so that a confirmation dialog will be shown every time when the user tries to reload a web page or navigate to another web page. You can use this callback to display an appropriate confirmation message dialog to ask the user if they really want to leave or reload the web page. To find out whether the web page is going to be reloaded you can check the Cause property.

Use the Stay method to stay on the current web page.

Use the Leave method to reload or navigate to another web page.

If the handler throws an exception, the Leave method will be used.

See Also