# PDL_RegisterJSHandler

## Description

Register a Plug-in handler function for JavaScript app invocation. Handler functions serve as interfaces between a JavaScript app and a Plug-in app. See JavaScript and Plug-in Interface for more information on how this works.

Notes:

- Before you register any functions, you must call `SDL_Init` with, at least, `SDL_INIT_VIDEO`. It is recommended that you register functions early in your app, so a good time to do this would be after calling `SDL_Init`.

- JS handler functions can NOT turn around and call a JavaScript function.

## Syntax

>     PDL_Err PDL_RegisterJSHandler(const char *functionName,
>       PDL_JSHandlerFunc function);

Argument | Description
--- | ---
functionName | The name the JavaScript application can use to reference the Plug-in handler function.
function | The Plug-in application function.

## Returns

>     PDL_NOERROR - Success.

## Example

>     PDL_Err err = PDL_RegisterJSHandler("foo", MyJSHandlerFunc);

Here, `"foo"` is the name the JavaScript app uses to reference the handler function. The second parameter is the name of the Plug-in handler function.

See also:

- PDL_JSRegistrationComplete
- PDL_GetNumJSParams
- PDL_GetJSParamDouble
- PDL_GetJSParamString
- PDL_GetJSParamInt
- PDL_JSException
- PDL_JSReply
- PDL_CallJS