Name: revBrowserAddJavaScriptHandler

Type: function

Syntax: revBrowserAddJavaScriptHandler <instanceID>, <handlerName> 

Summary: Adds the named handler to the 'LiveCode' object within the current JavaScript context of the browser.

Introduced: 6.7

OS: mac,windows

Platforms: desktop

Security: network

Example:
local tBrowserID
put revOpenBrowserCef(the windowId of this stack, "http://www.runrev.com") into tBrowserID
revBrowserAddJavaScriptHander, tBrowserID, "myLiveCodeHandler"

Parameters:
instanceID: the ID of the browser instance returned by the revOpenBrowser function.
handlerName: the name of a LiveCode handler in the script of the card / stack displaying the browser.

Description:
The  revBrowserAddJavaScriptHandler adds the named handler to the 'LiveCode' object within the currect JavaScript context of the browser.

The revBrowserAddJavaScriptHandler function will make the named LiveCode handler visible to JavaScript within the browser as a function belonging to the global JavaScript 'LiveCode' object. Calling this JavaScript function will result in a call to the LiveCode handler, which will be passed the browser instance as the first parameter followed by any parameters given to the JavaScript function.

Example:
A LiveCode card has the following handler:

on myLiveCodeHandler pID, pArg1, pArg2
   answer "Browser ID" && pID && "called myLiveCodeHandler with arguments" && pArg1 && "and" && pArg2
end myLiveCodeHandler

Registered within the JavaScript context with the following command:

revBrowserAddJavaScriptHander, tBrowserID, "myLiveCodeHandler"

The JavaScript code within the browser can then call the LiveCode handler via the registered function:

&lt;script ...&gt;

...

if (tIsRevBrowser)
liveCode.myBrowserHandler(tValue1, tValue2);

...

&lt;/script&gt;

References: revBrowserStop (command), revBrowserPrint (command), revBrowserSet (command), revBrowserMakeTextBigger (command), revBrowserNavigate (command), revBrowserRemoveJavaScriptHandler (command), revBrowserClose (command), revBrowserOpenCef (function), browserOver (message), browserNewInstance (message), browserNewUrlWindow (message), browserDownloadRequest (message), browserNavigateCompleteFrame (message)
