170 CHAPTER 6 (Florida web design) DECOUPLED NAVIGATION PATTERN In
170 CHAPTER 6 DECOUPLED NAVIGATION PATTERN In the example source code, the href property is http://www.apress.com, but the compar ison is the value http://www.apress.com/. Between the two buffers, there is a missing slash character. When the web browser processes the link element written as HTML, a slash is added to the href property. The added slash is not obvious to the script author and leads to a by-accident error, where by debugging you find out that a slash has been added. Using the id property, there is no translation by the web browser causing a by-accident error. Following is the rewritten HTML that uses id properties to identify each link:
Following is the MonitorLinks function rewritten to use the id property: function MonitorLinks( evt) evt = (evt) ? evt : ((event) ? event : null) if( evt) var elem = (evt.target) ? evt.target : E B V N ((evt.srcElement) ? evt.srcElement : null); if( elem) { if( elem.id == “apress”) { window.alert( “Not allowed on Apress”); return false; } else if( elem.id == “google”) { window.alert( “Not allowed on Google”); return false; } else if( elem.id == “slashdot”) { return true; } } } return false; } The HTML and the function implementation stay relatively the same, with the only real change being the addition and comparison of the id property. Other Ways to Define Events There are other ways to wire events. One popular other way is to retrieve the HTML element and then associate a function to that element. So, for example, if you were capturing the click event, you would assign the onclickproperty to a function. Then when a click occurs, an event
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.