JavaScript和JScript:有什么区别?

Netscape developed the original version of JavaScript for the second version of their popular browser. Initially, Netscape 2 was the only browser to support a scripting language and that language was originally called LiveScript. It was soon renamed JavaScript. This was in an attempt to cash in on some of the publicity that Sun's Java programming language was getting at that time.

Netscape为他们流行的浏览器的第二个版本开发了JavaScript的原始版本。 最初,Netscape 2是唯一支持脚本语言的浏览器,该语言最初称为LiveScript。 它很快被重命名为JavaScript。 这样做是为了利用Sun当时的Java 编程语言获得的一些知名度。

While JavaScript and Java are superficially alike they are completely different languages. This naming decision has caused numerous problems for beginners with both languages who continually get them confused. Just remember that JavaScript is not Java (and vice versa) and you will avoid a lot of confusion.

虽然JavaScript和Java从表面上看是一样的,但它们是完全不同的语言。 这个命名决定给使用这两种语言的初学者带来了很多问题,使他们不断感到困惑。 只要记住JavaScript不是Java(反之亦然),您就可以避免很多混乱。

Microsoft was attempting to capture market share from Netscape at the time Netscape created JavaScript and so with Internet Explorer 3 Microsoft introduced two scripting languages. One of these they based on visual basic and it was given the name VBscript. The second was a JavaScript lookalike which Microsoft called JScript.

在Netscape创建JavaScript时,Microsoft试图从Netscape夺取市场份额,因此Microsoft在Internet Explorer 3中引入了两种脚本语言。 其中之一基于视觉基础,并被命名为VBscript。 第二个是看起来像JavaScript的Microsoft称为JScript。

In order to try to outdo Netscape, JScript had a number of additional commands and features available that were not in JavaScript. JScript also had interfaces to Microsoft's ActiveX functionality as well.

为了超越Netscape,JScript提供了许多JavaScript中没有的其他命令和功能。 JScript还具有与Microsoft ActiveX功能的接口。

从旧浏览器隐藏 ( Hiding from Old Browsers )

Since Netscape 1, Internet Explorer 2, and other early browsers didn't understand either JavaScript or JScript it became a common practice to place all of the content of the script inside of an HTML comment so as to hide the script from older browsers. New browsers even if they couldn't handle scripts were designed to recognise the script tags themselves and so hiding the script by placing it in a comment was not required for any browsers released after IE3.

由于Netscape 1,Internet Explorer 2和其他早期的浏览器不了解JavaScript或JScript,因此将脚本的所有内容放在HTML注释中以便对较旧的浏览器隐藏脚本已成为一种惯例。 即使新的浏览器无法处理脚本,它们也可以自己识别脚本标签,因此,对于IE3之后发布的任何浏览器,都不需要通过将其放在注释中来隐藏脚本。

Unfortunately by the time that the extremely early browsers ceased to be used people had forgotten the reason for the HTML comment and so many people new to JavaScript still include these now completely unnecessary tags. In fact including the HTML comment can cause problems with modern browsers. If you use XHTML instead of HTML including the code inside a comment like that will have the effect of making the script a comment rather than a script. Many modern Content Management Systems (CMS) will do the same.

不幸的是,到极早期的浏览器不再使用时,人们已经忘记了HTML注释的原因,因此,许多JavaScript新手仍然包括这些现在完全不必要的标记。 实际上,包含HTML注释会导致现代浏览器出现问题。 如果您使用XHTML而不是HTML,则在注释中包含这样的代码将使脚本成为注释而不是脚本。 许多现代的内容管理系统(CMS)都会做同样的事情。

语言发展 ( Language Development )

Over time both JavaScript and JScript were extended to introduce new commands to improve their ability to interact with web pages. Both languages added new features that worked differently than the corresponding feature (if any) in the other language.

随着时间的流逝,JavaScript和JScript都被扩展以引入新的命令,以提高它们与网页交互的能力。 两种语言都添加了新功能,这些新功能的工作方式不同于另一种语言中的相应功能(如果有)。

The way the two languages work was just similar enough that it was possible to use browser sensing to work out whether the browser was Netscape or IE. The appropriate code for that browser could then be run. As the balance shifted toward IE gaining an equal share of the browser market with Netscape this incompatibility needed a resolution.

两种语言的工作方式非常相似,因此可以使用浏览器感知来确定浏览器是Netscape还是IE。 然后可以运行该浏览器的相应代码。 随着平衡向IE转移,获得与Netscape在浏览器市场上的平等份额,这种不兼容性需要解决。

Netscape's solution was to hand over control of JavaScript to the European Computer Manufacturers Association (ECMA). The Association formalized the JavaScript standards under the name ECMAscipt. At the same time, the World Wide Web Consortium (W3C) commenced work on a standard Document Object Model (DOM) that would be used to allow JavaScript and other scripting languages full access to manipulate all of the content of the page instead of the limited access that it had up until that time.

Netscape的解决方案是将JavaScript的控制权移交给欧洲计算机制造商协会(ECMA)。 该协会以ECMAscipt的名义正式制定了JavaScript标准。 同时,万维网联盟(W3C)开始研究标准文档对象模型(DOM),该模型将用于允许JavaScript和其他脚本语言完全访问以操纵页面的所有内容,而不受限制。访问到那时为止的时间。

Before the DOM standard was complete both Netscape and Microsoft released their own versions. Netscape 4 came with its own document.layer DOM and Internet Explorer 4 came with its own document.all DOM. Both of these document object models were made obsolete when people ceased using either of those browsers as all browsers since then have implemented the standard DOM.

在DOM标准完成之前,Netscape和Microsoft都发布了自己的版本。 Netscape 4带有自己的document.layer DOM,而Internet Explorer 4带有自己的document.all DOM。 当人们停止使用这些浏览器中的任何一个时,这两个文档对象模型都被淘汰了,因为从那时起所有浏览器都实现了标准DOM。

标准品 ( Standards )

ECMAscript and the introduction of the standard DOM in all of the version five and more recent browsers removed most of the incompatibilities between Javascript and JScript. While these two languages still have their differences it is now possible to write code that can run both as JScript in Internet Explorer and as JavaScript in all of the other modern browsers with very little feature sensing needed. Support for specific features may vary between browsers but we can test for those differences by making use of a feature built into both languages from the start that allows us to test if the browser supports a specific feature. By testing the specific features that not all browsers support we will be able to determine what code is appropriate to run in the current browser.

ECMAscript以及所有版本5和更新版本浏览器中引入的标准DOM消除了Javascript和JScript之间的大部分不兼容性。 尽管这两种语言仍然存在差异,但是现在可以编写既可以在Internet Explorer中作为JScript运行又可以在所有其他现代浏览器中以JavaScript运行的代码,而几乎不需要特征检测。 不同浏览器对特定功能的支持可能有所不同,但是我们可以从一开始就使用两种语言内置的功能来测试这些差异,从而使我们能够测试浏览器是否支持特定功能。 通过测试并非所有浏览器都支持的特定功能,我们将能够确定适合在当前浏览器中运行的代码。

差异性 ( Differences )

The biggest difference now between JavaScript and JScript are all of the additional commands that JScript supports that allow access to ActiveX and the local computer. These commands are intended for use on intranet sites where you know the configuration of all of the computers and that they are all running Internet Explorer.

JavaScript和JScript之间最大的区别是JScript支持的所有其他命令都允许访问ActiveX和本地计算机。 这些命令适用于Intranet站点 ,您可以在其中了解所有计算机的配置并且它们都在运行Internet Explorer。

There are still a few areas remaining where JavaScript and JScript differ in the means that they provide to perform a particular task. Except in these situations, the two languages can be considered to be equivalent to one another and so unless otherwise specified all of the references to JavaScript that you see will also usually include JScript.

JavaScript和JScript在执行特定任务所提供的方式上仍然存在一些差异。 除非在这些情况下,否则两种语言都可以视为彼此等效,因此,除非另行指定,否则您看到的所有对JavaScript的引用通常也将包括JScript。

翻译自: https://www.thoughtco.com/javascript-and-jscript-whats-the-difference-2037681

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值