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?
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.
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.
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.
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.
http://jurassic.codeplex.com
Although I don't know if it is Compact Framework compliant.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With