$H is a convenient method to create a Hash object. For details on the Hash object, please refer to [Prototype Learning - Hash Object]
$R is a convenient method to create an ObjectRange object. For details on the ObjectRange object, please refer to [Prototype Learning - ObjectRange Object]
Try.these:
Accepts an arbitrary number of functions and returns the result of the first one that doesn't throw an error.
//Use a loop nested try...catch to complete this tool function
var Try = {
these: function () {
var returnValue;
for (var i = 0, length = arguments.length; i < length; i ) {
var lambda = arguments[i];
try {
returnValue = lambda();
break;
} catch (e) { }
}
return returnValue;
}
};
Look at an example (different browsers have different ways of creating XMLHttpRequest):
getTransport: function() {
return Try.these(
function() { return new XMLHttpRequest() },
function() { return new ActiveXObject('Msxml2.XMLHTTP' ) },
function() { return new ActiveXObject('Microsoft.XMLHTTP')
} ) || false; }
document.getElementsByClassName():
According to this You can probably guess the purpose of this method from the name of the method. But this method was marked
deprecated in 1.6. Replaced by the $$ and Eelement.select methods. These two methods will be discussed later.