Fire-House 58

Objects

intro

o-1


JavaScript:
firehouse58.com objects are the definable elements of the browsers operating environment

 


Hard Reload
To See Menu

Objects

are the definable elements of the browsers operating environment. JavaScript uses objects to provide input and manipulate outputs. There are many objects. The window you are viewing this in is an object, and so is the document itself. JavaScript recognizes many objects, but you can also create your own objects. Consider an object you are familiar with, like your watch.We can indetify that object as:  watch

Objects have predefined Properties. Some of the properties of this document include its title, specified in the HTML tag <title>, and its background color, specified in the HTML tag <body bgcolor=. You can also assign additional properties to an object. The properties the watch object watch could be: watch.hands or watch.face or watch.digital.timer

Objects can also have Methods, or commands scripted to the object, that specify an action for the object. A method is used to manipulate an object. For example, a method to keep a browser window on top would be self.focus(). The methods used to manipulate your watch could be: watch.tick() or watch.digital.timer.start().

Event Handlers act as triggers causing an object to react to an event. Event handlers invoke an objects methods, or call functions defined in the script. In the example of your watch, an event handler onStart could be used to invoke a watch method onStart="timer.start()".

 

example:

     

Focus on this object.



<input type="text" size="20" name="two" value="try this"onFocus="this.value='see it change?';">

The object in this example is the text object  input type="text". It has the properties size, name& value. The property value was manipilated by invoking the event handler onFocus.


Objects are grouped in a Hierarchy, objects can be subsets of other objects. The hierarchy is a reference for accessing a documents objects, to determine the properties of those objects, or invoke the methods of those objects. If you think of your watch again you may refer to it in a hierarchy:

belongings
wardrobe   accessories
shoes   suit    ties   watch

therefore, your watch could be called
belongings.accessories.watch

to access the property time
belongings.accessories.watch.time

to use the method start
belongings.accessories.watch.timer.start()

 


[back]   [home]   [next]