Полезная информация

JScript Technical Articles
Start Page
Site Map
MSDN Online
 
JScript FAQ

Microsoft JScript Frequently Asked Questions

This FAQ covers the following questions:


What is JScript?

Microsoft JScript is a powerful scripting language targetted specifically at the Internet. It is implemented as a fast, portable, lightweight interpreter for use in World Wide Web browsers and other applications that use ActiveX™ Controls, OLE Automation servers, and Java applets.

How do I get JScript?

JScript is currently available as part of Microsoft Internet Explorer and Microsoft Internet Information Server. You can download the Internet Explorer.

Where can I find JScript Documentation?

Documentation will be available on the JScript web page in the future.

Where can I find Microsoft® Internet Explorer Object Model documentation?

The Object Model documentation for Internet Explorer 4.0 provides an overview of the object model, sample code (in JScript and in JavaScript), and reference information. It also describes the methods, properties, and events used with the scripting engines in Internet Explorer.

What are some of the known issues of Microsoft® Internet Explorer 4.0?

A complete list of known Microsoft® Internet Explorer 4.0 issues.

What support is there for JScript?

There are a variety of information options.

How does JScript compare to VBScript and Java?

When used in Internet Explorer, JScript is directly comparable to VBScript (not Java). Like VBScript, JScript is a pure interpreter that processes source code embedded directly in the HTML. JScript code, like VBScript code, does not produce stand-alone applets but is used to add intelligence and interactivity to HTML documents. For developers familiar with C and C++, JScript provides familiar syntax and language features.

What platforms will support JScript?

JScript is available or under development for Windows 95 and Windows NT (including native versions for the Alpha architecture), 16-bit Windows, and Macintosh. Microsoft is working with third parties to provide UNIX versions for Sun, HP, Digital, and IBM platforms.

I'm writing an application of my own that needs a scripting language. Can I use JScript as a scripting language for my application?

Yes. If you write it to support ActiveX Scripting, your application can host JScript and users of your application can use JScript. Because ActiveX Scripting is an open standard, your application can host any other language that is written to that standard. You must acknowledge the use of Microsoft technology and include the appropriate trademark and copyright information, but you can use and distribute JScript free of royalties.

What Objects, Methods, Properties, and Events can I use?

There are three separate classes of objects available within JScript:

  • Objects provided by the JScript engine
  • Objects provided by Internet Explorer
  • Objects provided by the web page author
The JScript engine provides the core run-time functionality, including a minimal set of basic objects. The vast majority of objects used in scripting are provided by Internet Explorer. In general, anything that is specific to the Internet is provided by IE, and anything that is generally useful is provided directly in JScript. The web author can insert additional objects through the <OBJECT> HTML tag.

The most complete documentation of the objects, methods, events, and properties available in Internet Explorer are available in the ActiveX SDK in the Object Model for Scripting section of the SDK Overview. The SDK can be downloaded from http://www.microsoft.com/intdev/sdk/.

This material can also be found through ActiveX Control Pad, a new authoring tool created by Microsoft. Select the Script Wizard while in the HTML view. The Object/Action view on the right then displays the Window object. Unfold it to reveal the complete object model beneath. Under Tools/Options, you can select code as the default view in the Script Wizard's bottom pane. Control Pad can be downloaded from http://www.microsoft.com/workshop/author/cpad/.

How can I write HTML text to the window?

You can use the document.write method to write any text, HTML or otherwise, to the window. These commands must be executed before the document has finished loading. The best way is to execute JScript commands that are inline, not subroutines or functions that are triggered by events.

How can I change the content of another frame?

Use parent.frames[1].location.href="filename.htm"
Note: Frames start numbering at 0, so if you have 2 frames, they are frames[0] and frames[1].

You can use the name of the frame instead of the index reference, as in:
parent.rightframe.location.href="filename.htm"

How can I get the value of an object property or variable in another frame?

Use top.framename.varname or parent.framename.varname. To get the value of a control property use top.framename.control.property.

How can I access an object in another frame?

top.framename.objectID (or parent...)
example: parent.controls.Axa1.FireImportedEvent 101

What is ECMAScript?

The ECMAScript standard describes a Web scripting language that can enrich and enliven Web pages in a Web browser. ECMAScript is the only standard scripting language on the Web; it is based on the ECMA-262 specification, which outlines an object-oriented programming language for performing computations and manipulating objects within a host environment, such as the browser. The complete ECMA-262 specification can be found at http://www.ecma.ch/stand/ecma-262.htm.

How is Microsoft supporting ECMAScript?

Microsoft Corp. is delivering JScript? development software version 3.0, the first scripting language to fully conform to the ECMA-262 specification, in MicrosoftR Internet Explorer 4.0, Internet Information Server 4.0, and the Windows Scripting Host. Microsoft is committed to the standards process and to continuing its active involvement in the ECMA process.

How do JScript and ECMAScript compare?

JScript 3.0 fully complies with the ECMAScript standard. In addition to this standard functionality, JScript 3.0 provides features that Microsoft submitted to be considered for the next ECMAScript specification, including the following:

Conditional compilation. Conditional compilation provides the ability to take different code paths depending on specified run-time variables. This way, script developers can write script targeted to specific platforms and browsers on the client machine.
Control flow enhancements. JScript provides new control structures for greater flexibility, including switch, label and do?while.
Regular expressions. JScript supports the new RegExp object for regular expressions, which are patterns used to match character combinations in strings and provide the developer with a powerful means of searching strings for particular character combinations.

How do JScript and JavaScript compare?

JScript fully complies with ECMAScript. JavaScript is not ECMAScript-compliant. While JavaScript 1.1 served as the basis for ECMA standards work, the standards process has resulted in significant language improvements in the areas of Unicode support, IEEE math functions and improved date functions.

Will JavaScript work in Internet Explorer 4.0?

Most functionality in JScript and JavaScript will work across both the Internet Explorer 4.0 and Netscape Navigator 4.0 browsers. The key issue here is that Internet Explorer 4.0 is already fully EMCA-compliant, while Netscape has announced that it intends to support ECMAScript. Internet Explorer 4.0 continues to lead in the standards arena, through its support for key standards such as ECMAScript.

Is Microsoft delivering JScript across platforms?

Yes. Microsoft is delivering JScript 3.0 or ECMAScript support in all versions of Microsoft Internet Explorer 4.0, including for 32-bit WindowsR operating systems, 16-bit Windows, Macintosh and UNIX platforms. The final release of Microsoft Internet Explorer 4.0 for Windows 95 and the Windows NTR operating system, Internet Explorer 4.0 Preview 1 for Macintosh and Internet Explorer 4.0 Preview 1 for Windows 3.1 and Windows NT 3.51 all support JScript 3.0 today.

I'm writing an application that needs a scripting language. Can I use JScript?

Yes. The binary and source code for JScript 3.0 is available today. This means that applications supporting the ActiveX? scripting interface can host JScript, and that users of these applications can use JScript. In addition, these applications can host any other language that is written to the ActiveX scripting interface. Microsoft's scripting site (http://www.microsoft.com/scripting/) describes in more detail how developers can distribute and use JScript in their applications at no charge.

To make script engine hosting even easier, Microsoft has released a beta of the Microsoft Script Control. This control allows any application that supports COM to host script engines with only two to three lines of code. The control can be used in Microsoft Visual Basic 5.0 and provides documentation on how to use the control within the Visual Basic environment. The Microsoft Script Control is free and can be downloaded from http://microsoft.com/scripting.

Note: Trademarks and copyrights are the property of their respective holders


© 1997 Microsoft Corporation. All rights reserved. Terms of Use.