且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

HTML脚本标记中允许使用哪种语言类型?

更新时间:2023-12-05 21:45:28

您可以在其中放置任何内容.这就是MIME类型的要点.

You can put anything you want in there. That's the whole point of MIME types.

当然,问题是用户的浏览器是否可以实际解释它.但这并不是真正针对<script>元素的.例如,我的浏览器仅了解样式表的CSS,其他浏览器也了解XSLT.我的浏览器仅了解文档的HTML,XHTML,HTML5,MathML和SVG,其他浏览器也了解PDF或不了解MathML.我的浏览器了解Alpha透明的PNG,而其他人则不懂.在GIF专利到期之前,有些浏览器不了解GIF,而其他浏览器则支付了许可费(或者非法使用了该专利,或者是在软件专利非法的司法辖区开发的),并且确实了解了GIF.有些浏览器可以理解H.264视频,而其他浏览器则可以使用Theora.

The question is of course whether or not your user's browser can actually interpret it. But that's not really specific to the <script> element. My browser, for example, only understands CSS for stylesheets, others also understand XSLT. My browser only understands HTML, XHTML, HTML5, MathML and SVG for documents, others also understand PDF or don't understand MathML. My browser understands alpha-transparent PNGs, others don't. Before the GIF patent ran out, there were some browsers that didn't understand GIFs, while others paid the licensing fees (or used the patent illegally or were developed in jurisdictions where software patents are illegal) and did understand GIFs. Some browsers understand H.264 videos, others Theora.

通常,保证所有浏览器都能理解的唯一语言是ECMAScript 3rd Edition.大多数浏览器也了解JavaScript的某些子集.

In general, the only language that is guaranteed to be understood by all browsers, is ECMAScript 3rd Edition. Most browsers also understand some subset of JavaScript.

许多版本的Internet Explorer都了解VBScript.

Many versions of Internet Explorer understand VBScript.

可以将CoffeeScript编译器编译为ECMAScript并嵌入到网站中,以便您可以通过text/coffeescript MIME类型在页面中使用CoffeeScript.

The CoffeeScript compiler can be compiled to ECMAScript and embedded into a website, so that you can use CoffeeScript in your page via the text/coffeescript MIME type.

有一个名为HotRuby的项目,这是一个用ECMAScript编写的YARV字节码解释器.它允许您使用text/ruby.

There's a project called HotRuby, which is a YARV bytecode interpreter written in ECMAScript. It allows you to use text/ruby.

Microsoft有一个名为Gestalt的项目,该项目使用Silverlight内部DLR之上运行的IronRuby和IronPython来提供对text/pythontext/ruby(以及可能在其上运行的任何语言)的支持. DLR的顶部,例如Scheme,Smalltalk,PHP,Tcl.)

Microsoft has a project called Gestalt, which uses IronRuby and IronPython running on top of the DLR inside Silverlight to provide support for text/python and text/ruby (and presumably any language that can run on top of the DLR, e.g. Scheme, Smalltalk, PHP, Tcl.)

Mozilla曾经有一个名为IronMonkey的项目,我相信,该项目将多个流行的执行引擎(例如MRI Ruby,CPython,Perl等)嵌入到Firefox中,从而允许将所有这些语言用于浏览器脚本.

Mozilla had a project a while back called IronMonkey, I believe, which embedded multiple popular execution engines, such as MRI Ruby, CPython, Perl and others into Firefox, allowing the use of all those languages for browser scripting.

我记得在某处读过有人为tcc(微型C编译器)支持构建了一个插件,它将允许您使用text/c.

I remember reading somewhere that someone built a plugin for tcc (tiny C compiler) support, which would allow you to use text/c.

就在几天前,Miguel de Icaza(Mono的创建者)建议将ISO CLI作为脚本平台添加到浏览器中,从而允许您使用CIL字节码通过application/cil MIME类型进行脚本编写

Just a couple of days ago, Miguel de Icaza (the creater of Mono) suggested that the ISO CLI should be added to the browser as a scripting platform, allowing you to use CIL bytecode for scripting via an application/cil MIME type.