简体   繁体   English

在浏览器之外解释JavaScript?

[英]Interpreting JavaScript outside of the browser?

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? 这更多是出于好奇,这是一个真正的要求,但我想知道是否可以将JavaScript视为(理想情况下)一流的.NET公民,或者(其次)有一些方法来调用/解释纯JavaScript函数(在桌面设置中不需要DOM)?

Has anyone ever attempted implementing a CLR version of JavaScript? 有没有人试图实现CLR版本的JavaScript? Something tugs at the back of my mind concerning this, but now that I think about it it was probably PHP, not JavaScript. 关于这一点,我想到了一些东西,但现在我想到它可能是PHP,而不是JavaScript。

对于你的第二个选择,有Rhino类似的东西

Using the DLR (Dynamic Language Runtime) you can use Managed JScript. 使用DLR(动态语言运行时),您可以使用Managed JScript。 See the official JScript blog from Microsoft here. 请在此处查看Microsoft的官方JScript博客。

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

This is goes for Ruby (IronRuby), Python (IronPython), and Dynamic VB. 这适用于Ruby(IronRuby),Python(IronPython)和Dynamic VB。 You can also write your own DLR language. 您也可以编写自己的DLR语言。

JScript is available on .NET as a first-class citizen. JScript作为一等公民在.NET上可用。 It's not exactly JavaScript, but it may be close enough for your needs. 它不完全是JavaScript,但可能足够接近您的需求。

According to this page, there used to be 2 "implementations" on the CLR: 根据这个页面,CLR上曾经有2个“实现”:

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

But both seem to be dead... 但两人似乎都死了......

It's perfectly possible to run JavaScript applications without the use of a web browser. 完全可以在不使用Web浏览器的情况下运行JavaScript应用程序。 You can do this just by running the application using cscript (typically javascript files end with .js). 您可以通过使用cscript运行应用程序(通常javascript文件以.js结尾)来完成此操作。

You can also run .js files with node.js . 您还可以使用node.js运行.js文件。 Hope this helps someone else. 希望这有助于其他人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM