JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak
-
Upload
amber-drake -
Category
Documents
-
view
51 -
download
0
description
Transcript of JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak
![Page 1: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/1.jpg)
JavaScript Programming an Introduction
Prepared ByP .D. Krolak and M.S. Krolak
Based on material from
JavaScript Unleashed (2nd Ed)
![Page 2: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/2.jpg)
JavaScript Objects• Objects hold data
•Objects have Properties that can be set and have values
•Objects can have Methods
![Page 3: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/3.jpg)
JavaScript
• JavaScript is a Programming Language, although not a complete one.
• JavaScript was developed by Netscape and is becoming an international standard
• JavaScript is sent with the HTML document and is interpreted at the time it is loaded on the browser
• JavaScript adds interaction
![Page 4: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/4.jpg)
JavaScript Objects
• JS is not true Object Oriented Programming (OOP) but object like
• What are the JS’s objects
• What is the JS object Hierarchy
• Built-In Language Objects
![Page 5: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/5.jpg)
JS is not true OOP but object like.
• JS objects do have properties and methods like and object orientated language.
• JS objects do not support inheritance.
• JS object model is a container model not a class model.
• Container objects contain other containers.
![Page 6: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/6.jpg)
What are the JS’s objects
• JavaScript objects fall into classes– Navigator Objects that mostly correspond to
HTML tags– Built-in Language Objects
![Page 7: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/7.jpg)
JavaScript Objects & Corresponding HTML Tags
window N/A
frame <frame>
document <body>
form <form>
button <Input Type=”button”>
checkbox <Input Type=”checkbox”>
fileUpload <Input Type=”file”>
![Page 8: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/8.jpg)
JS Object Hierarchy
![Page 9: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/9.jpg)
JS Window Object
• The Window Object contains all the objects.
![Page 10: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/10.jpg)
JS Navigator object
• Contains information about the browser.
• Properties can not be set by Javascript.
![Page 11: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/11.jpg)
JS History Object
• The History object records the documents that were displayed in order of their presentation – most recent descending to oldest.
![Page 12: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/12.jpg)
JS History Properties & Methods
Methods Description
Back () Go back n pages – no argument go to last page
Forward() Go forward n pages if possible,
Go() Go N pages where n >0 for forward and n<=0 for back.
![Page 13: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/13.jpg)
JS History Properties & Methods
![Page 14: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/14.jpg)
JS History Example
Create a back to last page link
<a HREF=“javascript:history.back();”>
Go to Last Page </a>
![Page 15: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/15.jpg)
JS Document Object
• Contains all the object that are contained in the document. The objects that are contained correspond to the HTML tags found on the web page.
![Page 16: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/16.jpg)
JS Location Object
• Location Object contains the information about the source of the document, i.e. the URL, and related information.
![Page 17: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/17.jpg)
JS Frame Object
• Contains information about the frames in the widow.
![Page 18: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/18.jpg)
Built-In Language Objects
• Built Objects do not appear in the Document but in the code.
• Built-in Objects include:– Array– Date– Math– String
![Page 19: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/19.jpg)
Array Object
![Page 20: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/20.jpg)
Date Object
![Page 21: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/21.jpg)
Math Object
![Page 22: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/22.jpg)
String Object
![Page 23: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/23.jpg)
JavaScript Properties
• Properties in JS resemble data attributes of an object
• Properties explain the characteristics and identity of the given object
• Properties can represent the state of the object
• Properties could represent the role that the object plays at a given time
![Page 24: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/24.jpg)
JavaScript Events & Event Handlers
• A javaScript event is controlled by browser based on action normally initiated by the viewer.
• Each tag has an associated set of event handlers that are triggered by a corresponding event. When the event handler is triggered, a javaScript is preformed.
![Page 25: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/25.jpg)
JavaScript Methods
• Methods are functions that provide services for the object
1. Set the value of a property
2. Get the value of a property
3. Iterate on the object’s properties
4. Constructor for the object.
![Page 26: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/26.jpg)
Embedding JS in HTML
![Page 27: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/27.jpg)
Embedding JS in HTML
• The <script> tag• Accommodating the Non JS supporting browsers
by using a comment to surround the content of the script within the container.
• Viewing the JS code• Executing the scripts• loading a page• HTML enhancements
![Page 28: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/28.jpg)
The <script> tag
• <script language=“JavaScript1.x”> where x can be version of JavaScript used, i.e 0,1,2,3. If the browser does not support the version the tag and its content is ignored.
• language can also be set to vb script, php, etc.• <Script > </Script> form the container• The script may be placed anywhere in the document but
must exit before needed.• Most scripts are placed in the head and are thus loaded
before they are needed for the display & interaction.• Scripts that contain document.write() must be in the
body.
![Page 29: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/29.jpg)
The <script> tag continued
• JavaScript libraries may be stored external to the HTML document.
• <script Language=javascript1.2 src=“Library’s_URL”>
• Library file extension must be “.js”
![Page 30: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/30.jpg)
Accommodating the Non JS supporting browsers
• The contents of the script container are commented so non JS browsers will ignore the contents.
• <Script ><! -- // the comment is used by the non-JS Your javaScript code here--></Script>
![Page 31: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/31.jpg)
Viewing the JS code
<Html>
<Head>
</Head>
<Body>
<script Language=“javascript1.2”>
document.write(“Hello World”);
</Script>
</Body>
</Html>
![Page 32: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/32.jpg)
Executing the scripts
• The scripts are not executed in any necessary order.
• They are executed as the flow of events dictates.
![Page 33: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/33.jpg)
Loading a page
• There is no difference in loading a page with a script or without.
![Page 34: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/34.jpg)
HTML enhancements
![Page 35: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/35.jpg)
JS Fundamentals
![Page 36: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/36.jpg)
Versions of JS
Version of Javascript Browser Support
Javascript 1.1 •Netscape 2.
Javascript 1.2 Netscape
Javascript 1.3 Netscape 4.
![Page 37: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/37.jpg)
JS Operators
• Assignment Operators
• Arithmetic Operators
• Comparison Operators
• String Operators
• Conditional Operators
• Boolean Operators
• The type of operators
![Page 38: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/38.jpg)
Arithmetic Assignment
Assignment Description
x += y x= x+y addition
x -=y x= x-y subtraction
x *= y x= x*y
x /= y x= x/y
x %= y x= x%y x mod (y)
![Page 39: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/39.jpg)
Assignment
![Page 40: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/40.jpg)
Arithmetic
![Page 41: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/41.jpg)
Arithmetic Operators
Operator Description
% or Mod 4%3 returns 1
++ Increment ++x sets x= x+1 and returns x+1 but x++ sets x=x+1 and returns x
-- Decrement --x sets x= x-1 and returns x-1 but x-- sets x=x-1 and returns x
- (uninary negation) Sets x = -x ,I.e reverses sign
![Page 42: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/42.jpg)
Comparison
![Page 43: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/43.jpg)
Comparison Operators
Operator Description
== Equal
!= Not Equal
> Greater than
>= Greater than or Equal
< Less than
<= Less than or Equal
![Page 44: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/44.jpg)
String
• String operators are the same as comparison, using a sort sequence
String a> b, or a>=b etc.
String has two forms of concatenate
1. a+b
2. a +=b
![Page 45: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/45.jpg)
String Operator
![Page 46: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/46.jpg)
Conditional
![Page 47: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/47.jpg)
Boolean
![Page 48: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/48.jpg)
JS Operators (continued)
• Function operators
• Data structure operators
• Bit wise operators
• Operator precedence
![Page 49: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/49.jpg)
Function Operator
![Page 50: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/50.jpg)
Statements
• Statements define the flow of the script.• JS statements require a “;” at the end if
there are more than one on a line. • A block of statement that are executed in
order is enclosed by curly brackets {}.• Flow is normally linear but may be altered
by conditional, looping, or similar statements.
![Page 51: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/51.jpg)
Comments
• Comments are not really part of the program statement but are provided for the programmer and others as notes and reminders of what is happening in the JS.
Statement; //single line comment
/* this the way to
create multi line comments */
![Page 52: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/52.jpg)
JS Control Structures and Looping
• Conditional statements
• Looping statements
• Labeled
• with
• switch
![Page 53: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/53.jpg)
Conditional statements
If …. else
If (condition)
{Block of Statements;}
else
{Block of Statements;}
![Page 54: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/54.jpg)
Looping statements
ForThe traditional for loop loops until the test condition
is false. The initial statement is executed once. The test is applied and if true, the Block of Statements are executed. The counter is incremented and test applied. Repeat looping.
for (initial_statement; test_condition; increment)
{Block of Statements;}
![Page 55: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/55.jpg)
Looping statements
For … inOn each iteration get one property of the
object. If the object has no properties the loop is not executed.
for (property in object)
{Block of Statements;}
![Page 56: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/56.jpg)
Looping statements
do …. while
Repeat the block statement until the condition is false.
(Note it goes thru loop at least once)
do
{ Block of Statements; }
while (condition)
![Page 57: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/57.jpg)
Looping statements
While
While executes as long as condition is true. Will not execute the first time if false.
While (condition)
{ Block of Statements;}
![Page 58: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/58.jpg)
Break & Continue Statements
• Break – Drop out of loop and go to statement following loop.
• Continue – Drop out of the loop block of statements and go to the loop control. Looping continues until control is false.
![Page 59: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/59.jpg)
Labeled
• Label statement – allows the break and continue statement to transfer to this label.
Label: statement;
![Page 60: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/60.jpg)
with
• Establishes an object as the point of reference.
with (object)
{Block of Statement;}
![Page 61: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/61.jpg)
switch
Switch is the JavaScript case statement.Switch (expression){
case label-1:{Block of Statements;}break….case label-n:{Block of Statements;}breakdefault:{Block of Statements;}
}
![Page 62: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/62.jpg)
JS as Object Orientated Language
• Object and Dot Notation
• Properties
• Methods
• Events
![Page 63: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/63.jpg)
Object and Dot Notation
• The object is described from the container that holds the container that holds .. the container. Read from left to right and the dot as contains.
Example the form object from the diagram
Window.document.form
![Page 64: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/64.jpg)
Object Dot Notation
• A property is:
Object.property where dot reads is_a
• A method is:
Object.method() where dot reads is_a
![Page 65: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/65.jpg)
Object Dot Notation
• Since a window contains everything, it is called self.
• In the Dot notation we can drop the window because it is contained by nothing and contains everything.
![Page 66: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/66.jpg)
Properties
![Page 67: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/67.jpg)
Methods
![Page 68: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/68.jpg)
Events
![Page 69: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/69.jpg)
JS Events and Event Handlers
![Page 70: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/70.jpg)
JS Object Constructor
• A method is a constuctor if it has the same name as the object an provides a template for creating an instance of the object.
Function object(parm1, … ){
This.property1 = parm1 ;..This.method1= function1..}
![Page 71: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/71.jpg)
Instantiating Objects
![Page 72: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/72.jpg)
Debugging JavaScript
![Page 73: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/73.jpg)
Debugging JavaScript
• First sign of trouble will appear as error message in the status window (lower left bottom of window).
When a error does appear then type:
Javascript: in the location window (where the document URL goes). Note the last character “:” is required. A series of error messages that will attempt to locate the error will appear in the dialog window.
![Page 74: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/74.jpg)
When creating JavaScript turn Javascript Console automatically 1. Can not be done through preference option But it can
done.
2. Go to the pref.js in the Netscape directory.
3. Open in a text editor.
4. Last line add:user_pref(“javascript.console.open_on_error”,
true);
5. Save file and Restart Netscape.
Console should pop up when a javascript error occurs.
![Page 75: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/75.jpg)
Netscape JS Debugger
• Download the JS debugger from their web site:
http://developer.netscape.com/software/jsdebug.html
![Page 76: JavaScript Programming an Introduction Prepared By P .D. Krolak and M.S. Krolak](https://reader035.fdocuments.net/reader035/viewer/2022062314/56812bc5550346895d900b78/html5/thumbnails/76.jpg)
JavaScript References