You do not need a web browser or WebBrowser control to use JavaScript in the .NET Framework. The .NET Framework has a built-in JavaScript implementation that implements a superset of JavaScript / ECMAScript, as described here and.
To use the NET Framework built into the JavaScript implementation:
- Add assembly link
Microsoft.JScript - Use
new JScriptCodeProvider().CreateCompiler().CompileAssemblyFromSource(...).CompiledAssemblyto compile JavaScript to assembly - Call the code in the compiled assembly as usual (GetType / GetMethod / Invoke)
Note that if your JavaScript code is designed to control the DOM or use other functions of the web browser, you can still use the version of JavaScript for the NET Framework, but you will need to provide the expected objects yourself.
source
share