类型= QUOT;文本/ ECMAScript的" vs type =" text / javascript" [英] type="text/ecmascript" vs type="text/javascript"

查看:86
本文介绍了类型= QUOT;文本/ ECMAScript的" vs type =" text / javascript"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读一本关于学习JavaScript的书,有这些段落:

I was reading a book about learning JavaScript, and there was these paragraphs:


... 1997年中期,微软和Netscape与
欧洲计算机制造商协会的联系人,

发布了名为 ECMAScript 的标准的第一个
版本或官方表格
ECMA-262 ...

...in middle of 1997, Microsoft and Netscape, with associate of European Computer Manufactures Association,

released the first version of a standard that named ECMAScript or with official form ECMA-262...

尽可能多我在本书中找到了类似的东西,JavaScript和ECMAScript是相同的,只是名称不同。

As much as I was found in this book and something like this, JavaScript and ECMAScript are the same and are different just in name.

另一方面,在Dreamweaver,括号和一些中其他编辑,有一些像这样的自动完成建议:

From other hand, in Dreamweaver, bracket, and some other editors, there's some autocomplete suggestion like this:

当我想在我的页面添加脚本标签时。

when I want to add a script tag to my page.

我想要知道 ECMAScript Javascript 之间是否存在差异,何时应该使用 text / javascript text / ecmascript

I want to know if there are differences between ECMAScript and Javascript and when should I use text/javascript or text/ecmascript?

推荐答案

ECMAScript是由ECMA International标准化的语言规范 ECMA-262 ISO / IEC 16262 。 JavaScript是一种实现此规范的编程语言。 ECMAScript存在多个版本。最新版本是第6版(2016年),但大多数JavaScript实现到目前为止仅符合第5版。

ECMAScript is a language specification standardized by ECMA International as ECMA-262 and ISO/IEC 16262. JavaScript is a programming language that implements this specification. ECMAScript exists in several editions. The latest edition is the 6th (in 2016), but most JavaScript implementations are only 5th edition compliant so far.

除了ECMAScript之外,常见的JavaScript实现通常会添加更多功能,由其他机构(如W3C)标准化,或者可能是特定实现的专有(也称为浏览器特定)功能。所以你可以说,ECMAScript代表JavaScript的一个子集。

Besides ECMAScript common JavaScript implementations usually add more functionality, which might be standardized by other institutions (like the W3C) or might be proprietary (aka "browser-specific") features of the specific implementation. So you could say, that ECMAScript represents a subset of JavaScript.

然而,JavaScript代码的MIME类型在 RFC 4329 文档,其中声明 text / javascript text / ecmascript 都已过时,应替换为 application / javascript application / ecmascript

However, the MIME types for JavaScript code are defined in the RFC 4329 document, which states that text/javascript and text/ecmascript are both obsolete and should be replaced by application/javascript and application/ecmascript:


对于这种内容,使用text顶级类型已知为
be有问题的。因此,本文档定义了text / javascript和text /
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定义更严格处理 application / ecmascript 的规则,而不是 application / javascript ,但这是指处理MIME类型参数和字符编码而不是代码本身的解释:

The RFC defines stricter processing rules for the application/ecmascript than for application/javascript, but this refers to the handling of MIME-type parameters and the character encoding and not to the interpretation of the code itself:


在引用的案例中,类型text / javascript,text的实现/ ecmascript和application / javascript应该和application / ecmascript类型的实现必须实现本节中定义的要求:[...]

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: [...]

对于application / ecmascript媒体类型,实现绝不能处理标有版本参数的内容,就像没有指定这样的参数一样; [...]

For the application/ecmascript media type, implementations MUST NOT process content labeled with a "version" parameter as if no such parameter had been specified; [...]

对于媒体类型text / javascript,text / ecmascript和application / javascript,以及媒体类型的REQUIRED,推荐以下错误处理行为application / ecmascript。

The following error processing behavior is RECOMMENDED for the media types text/javascript, text/ecmascript, and application/javascript, and REQUIRED for the media type application/ecmascript.

一般情况下,我会使用 application / javascript (或 text / javascript 如果您必须支持IE8等旧浏览器,以防止跨浏览器问题。如果你只关心HTML5,你也可以完全省略type-attribute。

In general I would use application/javascript (or text/javascript if you have to support older browsers like IE8) to prevent cross-browser issues. If you only care about HTML5, you can also omit the type-attribute completely.

这篇关于类型= QUOT;文本/ ECMAScript的" vs type =" text / javascript"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆