BOSON Help

WebView Events

The webview will automatically emit the following events (and intentions) during its lifecycle.

To subscribe to events, you can use direct access to the event listener, using WebView::$events property.

$app->events->addEventListener (Event::class, function (Event $e): void { var_dump($e); });

The webview instance also supports a more convenient and simple way of registering events using the on() method.

$app->webview->on(function (Event $event): void { var_dump($event); });

Dom Ready Event

An Boson\WebView\Event\WebViewDomReady event fired after webview DOM has been loaded and ready to work.

class WebViewDomReady<WebView>

Favicon Changing Intention

An Boson\WebView\Event\WebViewFaviconChanging intention to change the window's icon from loaded HTML content.

class WebViewFaviconChanging<WebView>

Favicon Changed Event

An Boson\WebView\Event\WebViewFaviconChanged event fired after the window's icon has been changed and the Boson\WebView\Event\WebViewFaviconChanging intention has not been cancelled.

class WebViewFaviconChanged<WebView>

Message Received Event

An Boson\WebView\Event\WebViewMessageReceived intention to receive message from the webview.

class WebViewMessageReceived<WebView> { public readonly string $message; public function ack(): void; }
  • $message - Received message string value.

An Boson\WebView\Event\WebViewNavigating intention to change the webview's URL (navigating to passed URL).

class WebViewNavigating<WebView> { public readonly string $url; public readonly bool $isNewWindow; public readonly bool $isRedirection; public readonly bool $isUserInitiated; }
  • $url - The URL address by which navigation occurs.

  • $isNewWindow - Navigation to the specified URL should have been made in a new window.

  • $isRedirection - Navigation to the specified URL occurs using a redirect.

  • $isUserInitiated - Navigation to the specified URL does not occur automatically, but is initialized by the user.

An Boson\WebView\Event\WebViewNavigated event fired after the webview has been navigated to the given URL and the Boson\WebView\Event\WebViewNavigating intention has not been cancelled.

class WebViewNavigated<WebView> { public readonly string $url; }
  • $url - The URL address by which navigation occurs.

Request Intention

An Boson\WebView\Event\WebViewRequest intention processing of user schemes registered in the configuration.

class WebViewRequest<WebView> { public readonly Boson\Http\RequestInterface $request; public ?Boson\Http\ResponseInterface $response = null; }
  • $request - Custom protocol request instance.

  • $response - An optional response instance containing the body string.

Title Changing Intention

An Boson\WebView\Event\WebViewTitleChanging intention to change the window title from loaded HTML content.

class WebViewTitleChanging<WebView> { public readonly string $title; }
  • $title - Expected title string to be set.

Title Changed Event

An Boson\WebView\Event\WebViewTitleChanged event fired after window title has been changed and the Boson\WebView\Event\WebViewTitleChanging intention has not been cancelled.

class WebViewTitleChanged<WebView> { public readonly string $title; }
  • $title - Title string from the HTML content of the webview.

08 May 2025