CHAPTER 6 DECOUPLED (Web server version) NAVIGATION PATTERN 167 The

CHAPTER 6 DECOUPLED NAVIGATION PATTERN 167 The statement tests whether the variable evt is null. If the value evt is not null, evt is assigned to evt, which in effect does nothing. The assignment is a placeholder assignment to provide an option to evt being null. However, if evt is null, most likely Microsoft Internet Explorer is being used. Then the variable evtneeds to be assigned to the event variable, which is always defined in Internet Explorer. The test is not necessary if the method is called as illustrated in the example. The reason has to do with how the OnClick function is called, which is illustrated again here:

Notice that OnClickis called with the event object instance and is compatible with Microsoft Internet Explorer. What is important to realize is that the event object instance is valid only in the context of the attribute onclick when using Mozilla-compatible browsers. When an HTML event is caught by a parent of the HTML element that triggers the event, the parent does not have immediate knowledge of the source of the event. This is the case of the OnClick function example implementation in that it can be called in multiple contexts, such as clicking the button, table cell, and so on. You will want to know the source element for manipulation purposes, but like the HTML event object, the property for the source element depends on the browser used. The source element can be found by referencing either the target or srcElement property. The following source code from OnClick illustrates how to retrieve the element that originally triggered the event: if( evt) { E B V N var elem = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); In the source code example, it is assumed that the evt variable instance is valid. The variable elem references the HTML element responsible for the event. After the assignment character, there is anexistence test of either evt.targetor evt.srcElement. If the browser is Mozilla based, the property evt.targetexists, and if the browser is Microsoft Internet Explorer, the property evt. srcElementexists. Other browsers will have a valid instance for one of the two properties. After both the event and target object instances have been retrieved, you can assign an HTML element innerHTML property to the identifier of the element that generated the event. Because all the HTML elements have been associated with an identifier, clicking on a cell of a table generates the identifier in the last row of the table, as illustrated in Figure 6-10. Figure 6-10 shows two balloons highlighted. The first balloon with the number 1 shows where a user clicked. This user clicked on the first row of the table. This generates an onclick event, which is given first to the td element, then to the trelement, then to the table element, and then finally to the div element which implements the onclick and generates the output. The generated output is highlighted in the second balloon.
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Leave a Reply