I am currently building a server-side application which runs browser-less JavaScript and TypeScript programs. The JavaScript engine I am currently using is Microsoft's JavaScript engine, "Chakra" (however looking at using JavaScript.NET since this hooks into Google's V8 engine in a more elegant manner).
I am programming my application using C# and .NET 4.0 (moving to 4.5 going forward)
So far I have faced a couple of problems, for example, if I run the following:
alert("Hello World");
I get an error because "alert" is undefined. Presumably this is implemented in the browser! (as would other objects such as HTMLElement, XMLHttpRequest etc)
What I want to know is, can I write JavaScript code that marshals code from .NET (or other managed/native systems)
For example:
function alert(message) {
//Performs call to .NET
MessageBox.Show("Hello World");
}
NOTES:
I have already done some research here:
Embedding JavaScript engine into .NET
Referencing Google's V8 engine from a .NET app
Javascript engine with good interoperability with JVM and CLR