ASP ScriptingJava ScriptingCGI ScriptingHTMLJavaLanguage CERP Education Links

JAVA SCRIPTING

Begin With Properties, Methods, Handling Events, Values, Variables

  Properties

     Objects have properties. A cat has fur, the computer has a keyboard, and the bicycle has wheels. In the JavaScript world, a window has a title, and a form has a check box.

     Properties can modify objects, and the same property can apply to completely different objects. Let's say that you have a property called empty. It's okay to use empty wherever it applies, so you could say that both the cat's tummy is empty and the cat's bowl is empty. Note that the computer's keyboard and the bicycle's wheels aren't only properties; they are also objects in their own right, which can have their own properties. So objects can have sub-objects.

  Methods

     The things that objects can do are called methods. Cats purr, computers crash, and bicycles roll. JavaScript 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.

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

  Handling Events

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

     JavaScript deals with events with commands called event handlers. An action by the user on the page triggers an event handler in your script. 

     In JavaScript, if the user clicks on a button, the onClick() event handler will take note of the action and perform whatever duties it was assigned.

    The twelve JavaScript event handlers are listed below :

  

Event Handler When Triggered Used in Tags of These Objects
onAbort The user aborted the loading the page <BODY>,<FRAMSET>
OnBlur When user moves the insertion point out of a field select,text,textarea
onChange After user changes contents of a field and moves select,text,textarea
onClick When the user clicks on an item button,checkbox,radio,link, reset, submit
onError The script encountered an error text,textarea
onFocus When the user moves the insertion point into a field select,text,textarea
onLoad When a document is loaded into view window <BODY>,<FRAMSET>
onMouseOver When user points to a hyperlink link <A>....</A>
onMouseOut The cursor moved off an object <A>....</A>
onSelect When the user selects text within a text or text area field text,textarea
onSubmit When the user submits a form <FORM>
onUnload When the user exits a document window <BODY>,<FRAMESET>

 
   Values and variables

     In JavaScript, a piece of information is a value. There are different kinds of values; the kind you're most familiar with are numbers. A string value is a word or words enclosed in quotes. 

     Variables contain values. For example, the variable myName is assigned the string "Barbie." Another way to write this is myName = "Barbie". The equals sign can be read as "is set to." In other words, the variable myName now contains the value "Barbie :".

     JavaScript is case sensitive. This means that myname is not the same as myName, and neither is the same as MyName.

    Variable names cannot contain spaces or other punctuation. They also can't be one of the JavaScript reserved words. 

 


Your Ad Here
Not All Of Your Subscribers Use RSS - AWeber Email Marketing
Your Ad Here