SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 130 | Next

Jonathan Snook, Aaron Gustafson, Stuart Langridge, and Dan Webb

"Accelerated DOM Scripting with Ajax, APIs, and Libraries"


Libraries solve these problems by automating much of the tedium as well as providing
a unified application programming interface (API) to various JavaScript and DOM features.
Libraries address the following issues:
??? Language extensions and bridges
??? Event handling
??? Ajax
??? Strings and templating
??? Working with collections
??? Handling JSON and XML
Language Extensions and Bridges
JavaScript and the DOM are great, but (as you saw in the last chapter) they weren??™t necessarily
designed to do certain things (for example, deep inheritance, in which one object
inherits from another, which inherits from another, and so on). Similarly, new language
features get implemented in some browsers, but take a while before being introduced into
other browsers. These features can be covered with a language bridge, which is a chunk of
code that makes the feature of one browser available in another browser. A great example
is the Array.push() method. Older browser versions such as Internet Explorer (IE) version 5
didn??™t support it. A simple function such as the following would be used to bridge the gap
between the support in IE 5 and other more modern browsers:
// if the method doesn't exist then add it in
if (!Array.prototype.push) {
Array.prototype.push = function(obj) {
this[this.length] = obj;
}
}
CHAPTER 4 n LIBRARIES 82
Event Handling
Event handling falls under the category of ???Language Extensions and Bridges,??? but I separated
it into its own section because it??™s so important.


Pages:
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
hire rtv domki stacjonarne tablice reklamowe brodziki