2 peachy
05-19-2003, 02:36 PM
Could someone please explain the differences between a property, method and event handler ?
I am a little confused about this.
I am a little confused about this.
|
Click to See Complete Forum and Search --> : property, method, event handler 2 peachy 05-19-2003, 02:36 PM Could someone please explain the differences between a property, method and event handler ? I am a little confused about this. Charles 05-19-2003, 03:05 PM An event handler simply handles and event. Not that that helps. In the old days the program was in control. To get keyboard input, the program would ask the operating system for it. These days the operating environment (OE) is in control and when some user input occurs, an event, it asks the program what to do. The event handlers register functions with the OE. In HTML you have 'onload' handlers for windows and images and the handlers will be called when the window or image is finished loading. The complete list of HTML event handlers can be found at http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.3. In JavaScript the handlers are each some method of some object. JavaScript has two broad categories of data structures, primitives and objects. Primitives are the variables of old, things like booleans, floating point reals, arrays and strings. Objects are a complex data structures. In the same way that an array can contain any number of the same kind of data structure, objects can contain any number of any kind of data structure. They are just like the tree structure of a hard drive. Variables that belong to an object are called properties. To address the 'title' property of the 'document' object you would use 'document.title'. Objects can also have functions that belong to them but they are then called methods like the 'document.write' method. In JavaScript methods and properties are almost the same thing. You can assign a value to what was a method: <script type="text/javascript"> <!-- document.write = 'foo'; alert (document.write); // --> </script> To make a function or method 'run' you have to call it with the () operator. And you can assign a function to a variable: <script type="text/javascript"> <!-- var foo = function () {alert ('foo')}; foo(); // --> </script> So, event handlers handle events, methods are object functions and properties are method variables. khalidali63 05-19-2003, 03:10 PM An event handler is a function or method that is used to respond and perform a prticular task when an event is triggered. such as onclick is an event and if you had a function that totals some values and u names it doTotal() that will be an event handler. method is a collection of some logic to to perform some actions as we had a method/function above used for onclick even handling. an object may have several properties,such as Color,backgroundcolor font,fontsize etc... 2 peachy 05-19-2003, 03:17 PM thankyou both so much for your quick responses I think I may actually start to understand JavaScript from all the wonderful help I get at this forum. Maybe even will someday start to be able to give back by helping others. 2 peachy 05-19-2003, 03:19 PM is JavaScript strictly a client-side technology ? Jona 05-19-2003, 03:21 PM Yes, it can only be used for client-side applications, which is why it has event handlers, and server-side languages do not have event handling. 2 peachy 05-19-2003, 03:24 PM Thankyou for your help. Jona 05-19-2003, 03:26 PM Wasn't exactly my business to join this discussion, but I thought I might as well help out a bit and give Charles a break. lol 2 peachy 05-19-2003, 03:34 PM I welcome your help as much as anyones.... I am trying to learn and this forum provides me with the best teachers I have ever found. Charles 05-19-2003, 04:03 PM However, there is such a thing as Server Side JavaScript just as there is such a thing as PerlScript which is Perl running on a browser. Nevermore 05-19-2003, 04:05 PM Finding a server for server side JavaScript, or a browser for PerlScript, could prove a tad difficult... Jona 05-19-2003, 04:23 PM This is true. Nevermore 05-20-2003, 01:06 AM I suppose youi could host your own server... webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |