Thursday, September 25, 2008

JavaScript

JavaScript

Tom Negrino

Dori Smith

What is JavaScript?

JavaScript is a programming language that you can use to add interactivity to your Web Pages. There are lots of JavaScript on the Web that you can copy and modify for your own use with a minimum of effort.

JavaScript is a script program that is include on an HTML page. It is enclosed in the <SCRIPT> tag, the text of the script doesn’t appear on the user screen, and the Web browser knows to run the JavaScript program. The <SCRIPT> tag is most often found within the <HEAD> section.

It is a object-oriented language.

Objects

Deals with in Web browsers such as windows, forms, and the elements of the form, such as buttons and check boxes.

TIP:

Be aware that scripts you might see on the Internet will refer to objects like window[0] and form[1]. This is poor style for the reason given above, and you will find that it’s much easier for you to keep track of different objects in your scripts if you give them names instead of numbers.

Properties

Object has a properties. A window has a title, and a form can have a check box.

Changing a property of an object can modify the object, and the same property can apply to complete different objects.

Methods

Objects also have methods: buttons click(), windows open(), and text can be selected(). The parentheses signal that we’re referring to a method, rather than a property.

TIP:

It might help you think of objects and properties as nouns, and methods as verbs. The former are things, and the latter are the actions that those things can do, or have done to them.

Handling Events

Events are the actions that the user perform while visiting your page. Submitting a form and moving a mouse over an image are two examples of events.

JavaScript deals with events using commands called event handlers.

Example:

onAbort – the user aborted loading the page

onBlur – the user left the object

onChange – the user change the object

onClick – the user clicked on an object

onError – the script encountered an error

onFocus – the user made an object active

onLoad – the object finished loading

onMouseover – the cursor move over an object

onMouseout – the cursor move off an object

onSelect – the user selected the contents of an object

onSubmit – the user submitted a form

onLoad – the user left the window

No comments: