Introduction to
JScript.
I have designed this site to teach about
the JScript. This is a general overview
of JScript used in teaching high school students.
I teach in Mathematics and programming languages and provides courses on Visual C++,
Visual C#, Visual Basic, C++, Java, PHP, MySQL, ASP.Net, Internet and
World Wide Web programming, and Object Technology.
Each
Exercise begins with a statement of objectives. This tells
the student what to expect and gives the student an opportunity, after
reading the text, to determine if he or she has met these objectives. It
is a confidence builder and a source of positive reinforcement. The learning
objectives are followed by a series of quotations. Some are humorous, some
are philosophical.
What is the
JScript and JavaScript.
Netscape introduced frames and LiveScript with
Navigator 2. Since then, LiveScript has evolved considerably. As a result of
its convergence of features with the Java programming language, it was
renamed to "JavaScript." Internet Explorer (IE) also supports JavaScript,
now, through Microsoft's implementation of "JScript." Since their
introduction, both JavaScript and JScript have grown explosively and are
used in many Web sites. One of its most popular features is the ability to
open multiple windows for browsing the Web. JScript
works in any version of Internet Explorer or Netscape Navigator on any
platform it supports.
Perl ,
perl is a scripting language,
it is the language used for the majority of CGI
scripts. These are routines that run on Internet servers and respond
to requests from browsers when a user completes a form. There are guestbook,
message boards, voting pages, surveys, and more that use Perl scripts. Perl is a
scripting language used in many CGI scripts on the Web,
Just as interactive scripts run as CGI scripts .
Back to top
Home
JScript is not
Javascript,
what is the difference between
JScript and JavaScript.
JavaScript is a cross-platform, interpreted, object-oriented language
originally designed for client-side web scripting. The elements of web pages
can be manipulated via JavaScript as objects specified by the Document
Object Model (DOM).
This enables dynamic effects like image roll-overs and interactive effects
like pages that change in response to user input without being reloaded from
the server.
JScript is Microsoft's
implementation of the language that contains similarities but also
differences.
Netscape originally developed a scripting language for use in its
browsers, calling it LiveScript. Java
being an internet buzzword at that time, for marketing reasons they renamed
the scripting language to JavaScript.
Microsoft implemented its own version of
JavaScript and called it JScript.
The standard is only about the core language, with data and objects
like numbers, strings, booleans, Object, Array, Function, Date, Math, but
not
about application specific objects like browser specific objects
(document, window, links, images etc).
The core features of Netscape’s JavaScript and Microsoft’s JScript
are pretty much compliant with the ECMA Script standard, but the
application specific objects like
the browser
DOM
(Document Object Model) and the server object model differ.
Most web browsers with the exception of Internet Explorer understand
Javascript and so the original unmodified code
worked properly in all of those browsers. Internet Explorer doesn't
understand Javascript. Instead it treats any
Javascript as if it were Microsoft's proprietary language
JScript and processes it accordingly thus
giving errors in IE when you use the same name for a variable as has been
assigned within the web page source.
Java
and
JScript Work in the Same Environment
One is compiled, the other is
interpreted. The development tools are
different, and they have a
surprisingly different audience. With JScript,
your pages come alive! Your pages respond to the requests of your audience
beyond a simple click here or there.
| JScript |
Java
|
| Interpreted by client | Compiled by the author, run on client
|
| Code integrated in HTML documents |
Applets distinct from HTML document
|
| Loose typing of data types | Strong typing of data types
|
| Dynamic binding | Static binding
|
| Script limited to browser functions |
Stand-alone applications
|
| Works with HTML elements | Goes beyond HTML (for example, multimedia)
|
| Access browser objects and functionality |
Limited access to browser objects or functionality
|
Back to top
Home
Learning JScript
is easy. By typing in just a few lines, you can be running a
JScript application.
JScript is based on an action-oriented model of the World Wide
Web. Java and
JScript are alike in more than just name.
However, there are significant differences between these two languages. As
you learn to understand the differences, you will also understand how they
can work together. Each has its place and neither does it all. Both
JScript and Java are languages for building Internet applications.
These applications require browsers. The browsers run these applications by
reading code embedded in an HTML page. In other words, they both work in the
same environment.
Microsoft has made it an open, cross-platform scripting language "JScript."
. This is the primary reason why JScript is
gaining wide acceptance. Several companies are expected either to
incorporate JScript into their products or to
provide an interface to JScript.
The most visible products will be the ActiveX
controls and plug-ins. Work is also underway to provide other features, such
as accessing high-end
databases
on the server. It will be interesting to see how this market develops.
All of this holds great potential for creating an exciting Web experience for
your viewers. You will be able to use the same language to enhance your Web
page, customize your server, create stunning effects with your controls and
plug-ins, and communicate with specialized Java applets.
JScript
can make your Web page come alive; it can make your site an unforgettable
experience that your users will want at the top of their favorites list.
Back to top
Home
Variables,
simple variables:
var x = 8 ;
Variables and Variable Names, the statement x
= 8 contains two components: the variable x and the value
8.
Data Types in JScript
There are five categories of data type, because it is possible to
distinguish two different types of numbers (integers and floating-point
numbers), and many different types of JScript objects, functions, and other
structured types.:1- A JScript value may be such as:
0 , 9 :2-
such as "Hello
to World " and 3- One of the
logical values true or false
.: 4- such as a function or
object. :5- The special value null.
Logical Values. The logical,
or Boolean, values true and
false are typically used in expressions that test some condition to
determine how to proceed. If that condition is met, one set of statements is
executed; if it is not, another set is used instead. The first corresponds
to the true condition, whereas the second represents the false
condition. Not surprisingly, such expressions are known as conditional
expressions. As you will see in the following section on "Operators,"
there are several comparison operators, such as the equality test (=
=), which result in logical values. It is possible to think of
true as 1 and false as 0. In fact, JScript often converts
these logical values into 1 and 0, respectively
Back to top
Home
Logical Operators.
Logical operators in JScript are used either to carry out some form of test,
or to combine the results of more than one such test. They are often
referred to as conditional operators. The logical operators that perform a
test of some sort are the equality/inequality operator (== and
!=), the comparison operators (<,
<=, >, and =>), and the logical negation operator
(!). The operators that combine logical values are logical AND (&&)
and logical OR (||). Finally, the conditional operator (?)
and the comma operator (,) are also combining operators, although
they are only vaguely logical operators.
Equality Operators.
The binary equality (==) and inequality (!=) operators are
used to test if two quantities are the same or different. These operators
are overloaded. On integers, they test for strict equality or inequality. On
floating-point numbers, they test to see whether the two quantities are
equal within the precision of the underlying floating-point type. On
strings, they test for exact equality-recall that case is significant in
JScript strings. These operators all return a Boolean value, either true
or false.
Back to top
Home
Control Structures:
(while,for,
if)
The if Statement:
The if statement is used to conditionally execute a single block
of code. It has two forms, the simple if statement and the
if...else statement. The simple if statement consists of a
conditional expression, known as the if test, and a block of code
which is executed if that expression evaluates to a Boolean true.
Functions and Objects
Functions and objects represent the highest level of organization within the
JScript language.
Introducing Object Orientation
About Objects.
The concepts and terminology of object orientation to help students
begin familiarizing themselves with what objects are and how they behave.
Back to top
Home
Methods in JScript
Objects, Properties
Before we can delve into object-oriented programming in
JScript, it is first necessary to review some of the basic concepts of
object-oriented programming itself. You have already had a brief
introduction in the "Functions and Objects"
Objects
What JScript calls an object is called a data structure (or class) in many
other languages. As with JScript functions, there are two aspects to JScript
objects: creating them and using them. A JScript object is made up of a set
of component parts, which are called its properties, or members.The
appointment object might have properties that specify the date and time of
the appointment, as well as the name of the person with whom the appointment
will take place. The pek
object will have the
properties: day,
month ,time,who
,why .Each of the properties
of the pek object is referenced using the dot
operator (.). Thus, pek.month
refers to the month property and
pek.why gives us the reason for the appointment.
JScript.net
can only
be used on the server side of an ASP.NET.
JScript
provides two ways to display data
The most common way to display information is the document.write( ),
and document.writeln( ), which are methods of
the document object, in alert, prompt, and confirm
message boxes.
Back to top
Home
1.
WScript.Echo ( " The
First program " );
WritingFirst Files (jscrip-xhtml)
and
in:
JScript.net
2.
var x =
WScript.CreateObject('WScript.Shell');
WScript.Echo('Hello JScript ');
var x = x.Popup('Click yes', 15, 'x==6 yes and x ==1 No ', 3);
if (x==6)
WScript.Echo( 'Outputs ' + ' \n ' + ' 2 + 2 = ' , (2 + 2 ) );
if (x ==1)
WScript.quite;
Back to top
Home
|