JScript

Definition of JScript in The Network Encyclopedia.

What is JScript?

An interpreted object-based scripting language supported by Microsoft Internet Explorer, Internet Information Services (IIS), and the Windows Scripting Host (WSH). Microsoft JScript version 5.0 is the first fully compliant implementation of the ECMA-262 specification for cross-platform, vendor-neutral scripting languages.

JScript enables Web developers to produce dynamic content for Web pages that can incorporate Microsoft ActiveX controls and Java applets. JScript cannot be used for developing stand-alone applications and has limited file input/output (I/O) features. It is a loosely typed language, which means that you don’t have to declare a variable’s data type before you use the variable.

How it works

Scripts written in JScript are embedded directly into Hypertext Markup Language (HTML) using <SCRIPT> tags, and the HTML files are stored on the Web server. When a Web browser such as Internet Explorer 4 accesses the page, it downloads and executes the script locally on the client machine. Internet Explorer can do this because it has a built-in scripting engine that can understand and interpret scripts written in JScript and Microsoft Visual Basic, Scripting Edition (VBScript).

The following is a simple example of a script written in JScript. The script is embedded in an HTML page between the <SCRIPT> and </SCRIPT> tags and displays a confirm message box when the user opens the file using Internet Explorer. When the user makes a selection, the remaining portion of the page loads.

<HTML>
<BODY>
<H1>Welcome to our restaurant!</H1>
<HR>
<SCRIPT>
var testing=window.confirm("Click OK for food.");
if (testing) {
window.alert("Hot dog");
} else window.alert("Beer");
</SCRIPT>
<H1>Thanks for coming!</H1>
</BODY>
</HTML>
NOTE

JScript 3 and JavaScript 1.2 are syntactically similar but have some differences. JScript 3 complies fully with the ECMA-262 specification, while JavaScript 1.2 does not. JScript also includes additional features not included in the ECMA-262 standard.

Graphic J-2. A dialog box created using JScript.

Web References