JScript
Encyclopedia
|
| Tutorials | Encyclopedia | Dictionary | Directory |
|
JScript
JScript is the Microsoft dialect of the ECMAScript scripting language specification. JavaScript (the Netscape/Mozilla implementation of the ECMA specification), JScript, and ECMAScript are very similar languages. In fact the name "JavaScript" is often used to refer to ECMAScript or JScript. JavaScript is used on web pages for scripting, although it can be and is also used in other embedding scenarios.
JScript is implemented as a Windows Script engine. This means that it can be "plugged in" to any application that supports Windows Script, such as Internet Explorer, Active Server Pages, and Windows Script Host. It also means that any application supporting Windows Script can use multiple languages ? JScript, VBScript, Perl, and others. JScript was first supported in Internet Explorer 3.0 browser released in August 1996. The typical file extension of JScript source code files is .js. The most recent version of JScript is JScript .NET, which is based on the yet-unfinished edition 4 of the ECMAScript standard, and can be compiled for the Microsoft .NET platform. JScript.NET adds several new features to ECMAScript ed. 3, such as optional static type annotations.
VersionsJScriptThe original JScript is an Active Scripting engine. Like other Active Scripting languages, it is built on the COM/OLE Automation platform and provides scripting capabilities to host applications. This is the version used when hosting JScript inside a Web page displayed by Internet Explorer, in an HTML application, in classic ASP, in Windows Script Host scripts and several other Automation environments. JScript is sometimes referred to as "classic JScript" or "Active Scripting JScript" to differentiate it from newer .NET-based versions.
Note (1): JScript supports various features not specified in the ECMA standard[2], as does JavaScript. Note (2): JScript 3.0 is "the first scripting language to fully conform to the ECMA-262 standard" (Source: Microsoft PressPass) Note (3): JScript 5.7 includes an implementation of the ECMAScript Compact Profile (ECMA-327) which turns off features not required by the ES-CP when using the "JScript.Compact" ProgID. JScript is also available on Windows CE (included in Windows Mobile, optional in Windows Embedded CE). The Windows CE version lacks Active Debugging. (Source: MSDN, WebmasterWorld Forum) Managed JScriptManaged JScript is an implementation of JScript for the Dynamic Language Runtime, it is part of Microsoft's dynamic languages for .NET along with IronRuby, IronPython, and Dynamic Visual Basic. Unlike JScript .NET which is less dynamic than the original JScript but provides CLS compatibility, Managed JScript is designed on top of the DLR and provides the features needed for scripting scenarios. While it is primarily designed to be used within Silverlight and ASP.NET at this time, it can also easily be embedded within any .NET application. (Source: JScript Blog, Jim Hugunin's Thinking Dynamic blog, Source: Blog of Jitu) Two builds of Managed JScript exists, one for the Desktop CLR and one for the CoreCLR (Microsoft Silverlight)
Managed JScript is not supported in the .NET Compact Framework. (Source: files versions of Microsoft.JScript.Runtime.dll in ASP.NET Futures and Silverlight 1.1 folders) JScript .NETJScript .NET is a Microsoft .NET implementation of JScript, it is a CLS language and thus inherit very powerful features, but lacks many features of the original JScript language, making it inappropriate for many scripting scenarios. JScript .NET can be used for ASP.NET pages and for complete .NET applications, but the lack of support for this language in Microsoft Visual Studio place it more as an upgrade path for classic ASP using classic JScript than as a new first-class language.
Note (4): JScript .NET is "being developed in conjunction with ECMAScript Edition 4" (Source: MSDN) JScript .NET is not supported in the .NET Compact Framework. Note JScript .NET versions are not related to classic JScript versions. JScript .NET is a separate product. Even though JScript .NET is not supported within the Visual Studio IDE, its versions are in sync with other .NET languages versions (C#, VB.NET, VC++) that follows their corresponding Visual Studio versions. .NET Framework 3.0 and 3.5 are built on top of 2.0 and do not include newer releases of JScript .NET. (Source: file version of Microsoft.JScript.dll in each framework install) SamplesClassic JScript can be used in many applications. Most common uses are client-side script in Internet Explorer and administrative scripts using the Windows Script Host (WSH, aka WScript). Because the application hosting JScript adds its own objects, functions and properties, the language has a limited set of built-in features and any real use depends on the hosting application. Managed JScript follows the same idea, and the hosting application adds objects to the engine. JScript in Windows Script HostThis sample shows how JScript uses COM/OLE Automation objects and enumerations, and how the WScript object, which is part of the Windows Script Host, is made available to JScript.
It can be simply saved as a .js script file and executed as it (it is associated with
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fldr = fso.getFolder("C:\\Windows");
var msg = new Array();
msg.push("Files in \""+ fldr.path +"\" :\r\n\r\n")
var ef = new Enumerator(fldr.files);
for( ef.moveFirst(); !ef.atEnd(); ef.moveNext() )
msg.push(ef.item().name +"\r\n");
WScript.echo(msg.join(""));
JScript in Internet ExplorerThis client-side sample shows how classic JScript works within Internet Explorer to execute script embedded in or linked from Web pages. Just like WSH makes the WScript object available to JScript, Internet Explorer makes the window object available to JScript, and makes all window members global members (document object, alert function, ?).
<html>
<head>
<script language="JScript">
function init()
{
var el = document.getElementById("dhtmlspan");
el.innerHTML = "Executed when done loading page.";
}
</script>
</head>
<body onload="init()">
<p>
<script language="JScript">
document.write("Executed during load.");
</script>
</p>
<p>
<span id="dhtmlspan">Please wait?</span>
</p>
</body>
</html>
JScript in Active Server PagesActive Server Pages (ASP) is an extension to IIS to run server-side Active Scripting code. Blocks between <% and %> are parsed and executed on the server, as well as standard script blocks with the runat argument set to "server". The ASP framework provides Request, Response and Server objects to the script engine to allow code to inject data in the response sent to the client and to retrieve data from the request (form, querystring, posted data).
<%@ language="JScript"%>
<html>
<body>
<%
Response.write("Executed server-side when generating the response.<br/>");
%>
<script language="JScript" runat="server">
Response.write("Executed last<br/>");
</script>
<%= "The = prefix is identical to Response.write.<br/>" %>
</body>
</html>
JScript .NETJScript .NET is a compiled language. It generates CIL binaries for stand-alone console and windows applications, libraries, or ASP.NET programs. The command-line compiler is included in the .NET Framework.
import System;
var _name;
Console.WriteLine("Hello, what's your name?");
Console.WriteLine("Type your name: ");
var _name = Console.ReadLine();
//provide a number and it will output it below, without error
Console.WriteLine("Hello, " + _name);
You can compile this file using JSC to generate a .exe file: JScript .NET can be used server-side for Web applications with the ASP.NET framework. Visual Studio usually generate code-behind, but inline code, similar to classic ASP, will get compiled to CIL and then executed on the fly.
<%@ Page Language="JScript"%>
<html>
<body>
<%
Response.Write("Compiled on the fly and executed server-side.<br/>");
%>
</body>
</html>
While the @ directive seems to imply classic JScript, ASP.NET pages (.aspx) never uses Active Scripting engines. It will try to load a .NET CLR language and this page will be processed by the JScript .NET compiler. Managed JScript in ASP.NETManaged JScript can be used server-side with ASP.NET with the DLR extensions. This is currently only available with the ASP.NET Futures preview.
<%@ Page Language="ManagedJScript"%>
<html>
<body>
<%
Response.Write("Executed on the fly server-side.<br/>");
%>
</body>
</html>
To be able to execute this on .NET 2.0, the DLR framework and Managed JScript references must be included in the Web.config assemblies references. Differences from JavaScriptJScript supports the conditional comment, but JavaScript does not. Other subtle differences exist, like the different behaviors that some methods exhibit (for example the RegExp methods). In addition to other internal implementation differences, JScript uses non-generational mark-and-sweep garbage collection[3] whereas JavaScript (the original implementation of which is the SpiderMonkey engine) uses a generational mark-and-sweep system. See also
ReferencesExternal links
JScript downloadsThe latest versions of classic JScript (5.6 and 5.7) are bundled with Internet Explorer, so it is already installed and up to date on many Windows computers.
The latest version for Windows 98, Me and NT4 is Windows Script 5.6, which used to be available on Microsoft Download Center but seems to have been removed when 5.7 went online.
Windows Vista already contains Windows Script 5.7. JScript .NET downloadsThe latest version of JScript .NET is bundled with the .NET Framework 2.0.
Managed JScript downloadsManaged JScript isn't final yet, but preview versions are bundled with Silverlight 1.1 preview and ASP.NET Futures preview.
de:JScript es:JScript fr:JScript id:JScript is:JScript nl:JScript ja:JScript pl:JScript ru:JScript sv:JScript tr:JScript uk:JScript zh:JScript Source: Wikipedia | The above article is available under the GNU FDL. | Edit this article
|
|
top
©2008-2009 TutorGig.com. All Rights Reserved. Privacy Statement