INTRODUCTION TO JAVASCRIPT
·
JavaScript is a
web enhancing language through which we can change a stand-alone page of
content into an engaging, interactive and intelligence experience
·
Developed by
Netscape Corporation
·
Initially known
as “Live Script”
·
JavaScript was
also referred to, as ECMA Script. (European Computer Manufacturer’s
Association)
JAVA VS. JAVASCRIPT
Java:
·
Purely an
object-oriented language
·
Compiled and the
resultant byte code is executed
·
Strongly typed
(declared variable cannot hold other data type value)
·
Object references
must exists at compile time (static binding)
JavaScript:
·
Object-Based
Scripting Language
·
The client
(browsers) directly interpret code
·
Freely typed (any
variable can hold any data type value)
·
Object references
are checked only at runtime (dynamic binding)
JAVASCRIPT CHARACTERISTICS AND ADVANTAGES
- ·
Object-based
Technology
- ·
Platform
Independent
- ·
Based on an
event-driven model
- ·
Control Frame
navigation
- ·
Include a plug-in
or Java applet inside a page
- ·
Validate HTML
submission forms
- ·
“Easy to Learn”
ENABLING JAVASCRIPT IN A BROWSER
MSIE:
Tools
menu > Internet Options from Internet Options window > Security tab >
Custom Level button Enable every setting for Scripting to allow JavaScript
pages
Mozilla Firefox:
Tools
menu > Options Options window > Content button Select Enable JavaScript
checkbox
OUR FIRST JAVASCRIPT PROGRAM
<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<BODY>
<SCRIPT TYPE = “text/javascript”>
document.write(“Hello World”);
</BODY>
</HTML>
HOW TO WRITE JAVASCRIPT
·
Codes are enclosed in
o
<SCRIPT>...</SCRIPT>
pair of tags
·
Attributes
o
SRC
o
TYPE
o
LANGUAGE
·
Guidelines in writing JavaScript
o
Case sensitive
o
Ignores
Whitespaces
o
Breakup a code
line
o
Use semicolon