0% found this document useful (0 votes)
46 views

Introduction To Java Scripts

The document provides an introduction to JavaScript, including that it was created to add interactivity to webpages, is written in plain text files with a .js extension, and can be used to validate forms, alert users, store temporary data, and perform calculations on the frontend. It notes that JavaScript has no relation to Java, and is a vast language where we will only cover relevant parts. Objects in JavaScript are entities with state and behavior like cars and pens. JavaScript is object-based, not class-based, and objects are directly created. The DOM represents document structure as a logical tree of nodes and objects that can be programmatically accessed to change structure, style, or content.

Uploaded by

head manager
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Introduction To Java Scripts

The document provides an introduction to JavaScript, including that it was created to add interactivity to webpages, is written in plain text files with a .js extension, and can be used to validate forms, alert users, store temporary data, and perform calculations on the frontend. It notes that JavaScript has no relation to Java, and is a vast language where we will only cover relevant parts. Objects in JavaScript are entities with state and behavior like cars and pens. JavaScript is object-based, not class-based, and objects are directly created. The DOM represents document structure as a logical tree of nodes and objects that can be programmatically accessed to change structure, style, or content.

Uploaded by

head manager
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 5

Introduction to Java Scripts

Now that we’ve gotten a bird’s-eye view of JavaScript, let’s get into the more technical detail. JavaScript
was created to add ‘life to webpages’. Just like HTML and CSS, JavaScript is written in plain text files with
a .js extension.

As previously mentioned, JavaScript can be used to accomplish many useful operations on the frontend,
like validating forms, alerting users, storing temporary data, and performing calculations—to name just a
few.

Apart from the name itself, JavaScript has no relation to Java. Beginners often get confused ip: between
the two languages. Remember that Java is an entirely different language made for a different purpose
(although you’ll still find it running on certain website backends).

Lastly, before we look at today’s itinerary, remember that JavaScript, just like HTML and CSS (but maybe
even more so), is a vast language. We’ll only be learning parts of it that are relevant to us today, so we’ll
list some good resources at the end if you’d like to learn more.

Objects in Java Script.


A javaScript object is an entity having state and behavior (properties and method). For example: car, pen,
bike, chair, glass, keyboard, monitor etc.

JavaScript is an object-based language. Everything is an object in JavaScript.

JavaScript is template based not class based. Here, we don't create class to get the object. But, we direct
create objects.

Dynamic HTML with Java Script. XML:


XML provides a standard way to define markup languages. Many such vocabularies and grammars have
been defined for many different types of data in many different industries. There has not been an XML
schema defined to represent Dynamic HTML files, and there's no reason to expect one to be: The
standard ways to combine HTML and JavaScript have been long established and standardized, and there
would be no benefit to duplicate those mechanisms in XML.

Document type definition,


A Document Type Definition (DTD) describes the tree structure of a document and something about its
data. It is a set of markup affirmations that actually define a type of document for the SGML family, like
GML, SGML, HTML, XML.

A DTD can be declared inside an XML document as inline or as an external recommendation. DTD
determines how many times a node should appear, and how their child nodes are ordered.

XML Schemas,
An XML schema is a description of a type of XML document, typically expressed in terms of constraints
on the structure and content of documents of that type, above and beyond the basic syntactical
constraints imposed by XML itself. These constraints are generally expressed using some combination of
grammatical rules governing the order of elements, Boolean predicates that the content must satisfy,
data types governing the content of elements and attributes, and more specialized rules such as
uniqueness and referential integrity constraints.

Document Object model,


The Document Object Model (DOM) connects web pages to scripts or programming languages by
representing the structure of a document—such as the HTML representing a web page—in memory.
Usually it refers to JavaScript, even though modeling HTML, SVG, or XML documents as objects are not
part of the core JavaScript language.

The DOM represents a document with a logical tree. Each branch of the tree ends in a node, and each
node contains objects. DOM methods allow programmatic access to the tree. With them, you can
change the document's structure, style, or content.

Presenting XML
Presenting XML is a Java web application framework for presenting HTML, PDF, WML etc. in a device
independent manner. It aims to achieve a complete separation of content and presentation. It supports
various kinds of content including XML files, dynamic content, SQL result sets and flat files. It provides a
declarative way for applying filters and XSLT transforms to a stream of XML content in a pipeline. It
allows user defined filters and serializers written as Java plug-ins. It is component based and extendible.

Presenting XML may be used as a command line tool or as a framework for a servlet-based web
application. Simple examples with XML, XSLT, and Java are included in the distribution. There are
command line examples for converting flat files to XML (and vice versa), for converting SQL results to
XML, for applying a sequence of XSLT transforms and SAX filters in a pipeline, and for setting up
streaming filters.

REVIEW OF APPLETS:
Applets are small applications that are accessed on an Internet server, transported over the

Internet, automatically installed, and run as part of a Web document.

After an applet arrives on the client, it has limited access to resources, so that it can produce an

arbitrary multimedia user interface and run complex computations without introducing the risk of
viruses or breaching data integrity.

APPLET CLASS:
The Applet class is contained in the java.applet package. Applet contains several methods that

give you detailed control over the execution of your applet. All applets are subclasses of Applet. Thus, all

applets must import java.applet. Applets must also import java.awt. Since all applets run in a window, it

is necessary to include support for that window. Applets are not executed by the console-based Java

run-time interpreter. Rather, they are executed by either a Web browser or an applet viewer.

Execution of an applet does not begin at main( ). Actually, few applets even have main( )

methods. Instead, execution of an applet is started and controlled with an entirely different mechanism.

Output to your applet’s window is not performed by System.out.println( ). Rather, it is handled with

various AWT methods, such as drawString( ), which outputs a string to a specified X,Y location. Input is

also handled differently than in an application.

Once an applet has been compiled, it is included in an HTML file using the APPLET tag. The applet

will be executed by a Java-enabled web browser when it encounters the APPLET tag within the HTML

file. To view and test an applet more conveniently, simply include a comment at the head of your Java

source code file that contains the APPLET tag. This way, your code is documented with the necessary

HTML statements needed by your applet, and you can test the compiled applet by starting the applet
viewer with your Java source code file specified as the target. Here is an example of such a comment:

/*

<applet code="MyApplet" width=200 height=60>

</applet>

*/

This comment contains an APPLET tag that will run an applet called MyApplet in a window that is

200 pixels wide and 60 pixels high.

EVENT HANDLING:
As Applets are event-driven programs, event handling is at the core of successful applet

programming. Most events to which your applet will respond are generated by the user. These events

are passed to your applet in a variety of ways, with the specific method depending upon the actual

event. There are several types of events. The most commonly handled events are those generated by

the mouse, the keyboard, and various controls, such as a push button. Events are supported by the

java.awt.event package.

The modern approach to handling events is based on the delegation event model, which defines

standard and consistent mechanisms to generate and process events. Its concept is quite simple: a

source generates an event and sends it to one or more listeners. In this scheme, the listener simply waits

until it receives an event. Once received, the listener processes the event and then returns. The

advantage of this design is that the application logic that processes events is cleanly separated from the

user interface logic that generates those events. A user interface element is able to “delegate” the

processing of an event to a separate piece of code.

In the delegation event model, listeners must register with a source in order to receive an event

notification. This provides an important benefit: notifications are sent only to listeners that want to

receive them. This is a more efficient way to handle events than the design used by the old Java 1.0
approach.

AWT PROGRAMMING:
The AWT contains numerous classes and methods that allow you to create and manage

windows. Although the main purpose of the AWT is to support applet windows, it can also be used to

create stand-alone windows that run in a GUI environment, such as Windows.

You might also like