…in middle of 1997,Microsoft and Netscape,with associate of
European Computer Manufactures Association,released the first
version of a standard that namedECMAScript
or with official form
ECMA-262
…
就像我在这本书中发现的一样,像这样的东西,JavaScript和ECMAScript是一样的,只是名字不同.
另一方面,在Dreamweaver,支架和其他编辑器中,有一些自动填充建议如下:
我想知道ECMAScript和Javascript之间是否存在差异,何时应该使用text / javascript或者text / ecmascript?
解决方法
除了ECMAScript,通常的JavaScript实现通常会增加更多的功能,这些功能可能被其他机构(如W3C)标准化,或者可能是特定实现的专有(特定“浏览器特定”)功能.所以你可以说,ECMAScript代表了JavaScript的一个子集.
但是,JavaScript代码的MIME类型在RFC 4329文档中定义,其中指出text / javascript和text / ecmascript都已过时,应该被application / javascript和application / ecmascript替代:
Use of the “text” top-level type for this kind of content is known to
be problematic. This document thus defines text/javascript and text/
ecmascript but marks them as “obsolete”.
RFC为应用程序/ ecmascript定义了比应用程序/ javascript更严格的处理规则,但这是指MIME类型参数和字符编码的处理,而不是对代码本身的解释:
In the cited case,implementations of the types text/javascript,text/ecmascript,and application/javascript SHOULD and implementations of the type application/ecmascript MUST implement the requirements defined in this section: […]
For the application/ecmascript media type,implementations MUST NOT process content labeled with a “version” parameter as if no such parameter had been specified; […]
The following error processing behavior is RECOMMENDED for the media types text/javascript,and application/javascript,and required for the media type application/ecmascript.
一般来说,我将使用应用程序/ javascript(或文本/ javascript,如果您必须支持像IE8之类的旧版浏览器),以防止跨浏览器问题.