$H is a convenient way to establish a hash object, specific reference to the hash object "Prototype Learning--hash Object"
$R is the easy way to resume Objectrange object, about Objectrange object specific reference "Prototype Learning--objectrange Object"
Try.these:
Accepts a arbitrary number of functions and returns the result of the ' the ' of the ' the ' of the ' the ' the ' the ' doesn ' t throw '.
Copy Code code as follows:
is to 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 to create XMLHttpRequest):
Copy Code code as follows:
Gettransport:function () {
Return Try.these (
function () {return new XMLHttpRequest ()},
function () {return new ActiveXObject (' Msxml2.xmlhttp ')},
function () {return new ActiveXObject (' Microsoft.XMLHTTP ')
} ) || False }
Document.getelementsbyclassname ():
The name of this method probably guesses the purpose of this method. But this method is marked in 1.6
It's deprecated. Replaced by the $$ and Eelement.select methods, the two methods are discussed later.