register_script_message_handler


Description:

[ Version ( since = "2.8" ) ]
public bool register_script_message_handler (string name)

Registers a new user script message handler.

After it is registered, scripts can use `window.webkit.messageHandlers.<name>.postMessage(value)` to send messages. Those messages are received by connecting handlers to the script_message_received signal. The handler name is used as the detail of the signal. To avoid race conditions between registering the handler name, and starting to receive the signals, it is recommended to connect to the signal *before* registering the handler name:

```c WebKitWebView *view = webkit_web_view_new (); WebKitUserContentManager *manager = webkit_web_view_get_user_content_manager (); g_signal_connect (manager, "script-message-received:WebKitUserContentManager:foobar", G_CALLBACK (handle_script_message), NULL); webkit_user_content_manager_register_script_message_handler (manager, "foobar"); ```

Registering a script message handler will fail if the requested name has been already registered before.

Parameters:

this

A UserContentManager

name

Name of the script message channel

Returns:

true if message handler was registered successfully, or false otherwise.