Interpreting JavaScript outside of the browser?

荒凉一梦 提交于 2019-12-30 00:31:10

问题


This is more out of curiosity that a real requirement, but I'm wondering if it's possible to treat JavaScript as (ideally) a first-class .NET citizen, or (secondarily) have some way of invoking/interpreting pure JavaScript functions (that don't require the DOM) in a desktop setting?

Has anyone ever attempted implementing a CLR version of JavaScript? Something tugs at the back of my mind concerning this, but now that I think about it it was probably PHP, not JavaScript.


回答1:


For your second option, there's Rhino and things like it.




回答2:


Using the DLR (Dynamic Language Runtime) you can use Managed JScript. See the official JScript blog from Microsoft here.

http://blogs.msdn.com/jscript/archive/2007/05/04/managed-jscript-announced.aspx

This is goes for Ruby (IronRuby), Python (IronPython), and Dynamic VB. You can also write your own DLR language.




回答3:


JScript is available on .NET as a first-class citizen. It's not exactly JavaScript, but it may be close enough for your needs.




回答4:


According to this page, there used to be 2 "implementations" on the CLR:

http://blogs.ugidotnet.org/nettools/articles/8060.aspx

But both seem to be dead...




回答5:


It's perfectly possible to run JavaScript applications without the use of a web browser. You can do this just by running the application using cscript (typically javascript files end with .js).




回答6:


You can also run .js files with node.js. Hope this helps someone else.



来源:https://stackoverflow.com/questions/648568/interpreting-javascript-outside-of-the-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!