Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Interpreter for .NET

I've got a scenario where I need to run a Javascript interpreter in a .NET application. This is going to be running on Windows Phone 7, so it needs to be Compact Framework-compliant and because it probably won't be pre-packaged for Windows Phone source could help there.

Also the licensing can be an issue. We looked at using Jint which is under an MIT license, but it uses Antlr, which is under a BSD license (as I understand it Jint is in non-compliance for not redistributing the Antlr copyright and conditions). Any other alternatives out there?

like image 906
Hounshell Avatar asked Mar 21 '11 20:03

Hounshell


People also ask

Can .net be used with JavaScript?

NET code can do virtually anything when combined with HTML and CSS but JavaScript is still very important and the reason lies in the different domains in which each language operates.

Is there a JavaScript interpreter?

In contrast, JavaScript has no compilation step. Instead, an interpreter in the browser reads over the JavaScript code, interprets each line, and runs it. More modern browsers use a technology known as Just-In-Time (JIT) compilation, which compiles JavaScript to executable bytecode just as it is about to run.

How do you use js in Blazor?

To invoke JavaScript functions from Blazor, you need an instance of the IJSRuntime interface. You can now use the js variable throughout the component. This method will invoke the specified JavaScript function. It requires 1 parameter; A string to specify which JavaScript function to run.


3 Answers

Since this question was asked, Jurassic has been released. This is a .NET Javascript interpreter that works on the full CLR as well as the phone (or so they claim).

I haven't started to migrate to it yet, so I don't know if it works, but here it is for any of you that are interested.

like image 78
Hounshell Avatar answered Oct 10 '22 19:10

Hounshell


http://jurassic.codeplex.com

Although I don't know if it is Compact Framework compliant.

like image 24
Einar Egilsson Avatar answered Oct 10 '22 19:10

Einar Egilsson


You can make JavaScript calls using the web browser control. It requires no additional libraries. You will need to do a little hacking around to make the control invisible, retrieving data etc, but it should do the trick.

Or you can try this project:

Javascript .NET integrates Google's V8 Javascript engine and exposes it to the CLI environment. Javascript .NET compiles (at runtime) and executes scripts directly from .NET code. It allows CLI objects to be exposed and manipulated directly from the executed Javascript.

like image 31
Byron Whitlock Avatar answered Oct 10 '22 20:10

Byron Whitlock