Prototype 工具函数 学习

网络编程 发布日期:2024/10/13 浏览次数:1

正在浏览:Prototype 工具函数 学习
$H就是建立Hash对象的便捷方法,关于Hash对象具体参考【Prototype 学习——Hash对象 】
$R就是简历ObjectRange对象的便捷方法,关于ObjectRange对象具体参考【Prototype 学习——ObjectRange对象 】
Try.these:
Accepts an arbitrary number of functions and returns the result of the first one that doesn't throw an error.
复制代码 代码如下:
//就是用一个循环嵌套try...catch完成这个工具函数的
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;
}
};

看一个例子(不同的浏览器有不同的创建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():
根据这个方法的名字大概就能猜到这个方法的用途了。但是这个方法在1.6里面被标记成
deprecated的了。被$$和Eelement.select方法代替了,关于这两个方法,后面在讲。
Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。