This project is read-only.

Subscribing to a .Net from JavaScript

Nov 23, 2011 at 4:46 PM

I am trying to subscribe a javascript function to a .Net event so I can callback into the javascript code when the event is fired.

I have my context have an input parameter set

context.SetParameter("myObject", myObject);


and myObject has an event called MouseClicked so I try the following from the code executing in my JavaScri0pt context:

myObject.MouseClicked += MouseClicked;


This runs without error, however when the objects MouseClicked event is invoked the code does not call back to the javascript function.

Is this possible?



Nov 23, 2011 at 9:27 PM

Since is a dead project, you may want to use Jurassic.

Jurassic and C# interactions are better because it is written in C#.

But Jurassic is slower.

Nov 24, 2011 at 4:28 PM

Thanks the reply.  I am keen on using the V8 engine in particular from .Net.


None-the-less if anyone knows how this can be achieved using this JavaScript .Net please let me know.  I'll be raking through the source code to see if I can figure out how in the meantime as I see there is mention of delegates in there.



Nov 24, 2011 at 7:23 PM

I did not see any example of what you want to do and it may be difficult because uses V8 which Just in time compile the javascript source  and therefore

it is going to be difficult to bridge the x86 binary world and the managed world. I have done some thing but I only set or get variable and object but no code 


Here is my post :

Nov 24, 2011 at 9:01 PM

JavaScript does not support subscribing to events via +=, so I have no idea what would have occurred when you executed "myObject.MouseClicked += MouseClicked".  I would guess that you need to

  1. Hold open your JavascriptContext.
  2. Somehow intercept the +=, or create your own call to attach handlers to events.
  3. Attach a C# stub that packages up the JavaScript function to invoke.
  4. Invoke it from the stub, somehow.