几个常用的Javascript函数
来源:互联网 发布:新疆纯种俄罗斯族知乎 编辑:程序博客网 时间:2024/06/09 19:57
// *******************************************************
// replacements for unsupported array functions (because arrayname.push(var)
// and arrayname.pop() are not implemented in IE until version 5.5)
function thearrayisgood(thearray,i) {
if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
return false;
else
return true;
}
function getarraysize(thearray) {
// replacement for arrayname.length property
for (i = 0; i < thearray.length; i++) {
if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
return i;
}
return thearray.length;
}
function arraypush(thearray,value) {
// replacement for arrayname.push(value)
thearraysize = getarraysize(thearray);
thearray[thearraysize] = value;
return thearray[thearraysize];
}
function arraypop(thearray) {
// replacement for arrayname.pop()
thearraysize = getarraysize(thearray);
retval = thearray[thearraysize - 1];
delete thearray[thearraysize - 1];
thearray.length--; <<==我加了这句,很关键,否则出错
return retval;
}
// *******************************************************
另外给出网上几个老外写的
function Array_pop() {
var response = this[this.length - 1]
this.length--
return response
}
if (typeof(Array.prototype.pop) == "undefined") {
Array.prototype.pop = Array_pop
}
function Array_push() {
var A_p = 0
for (A_p = 0; A_p < arguments.length; A_p++) {
this[this.length] = arguments[A_p]
}
return this.length
}
if (typeof Array.prototype.push == "undefined") {
Array.prototype.push = Array_push
}
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- 几个常用的Javascript函数
- Javascript中常用的几个数字函数
- JavaScript 的几个函数
- 几个常用的javascript函数,非常有用,爽~~~~~
- 发现了在公司的电脑中影响Windows性能,造成硬盘唱狂响曲的罪魁祸首!
- [Z]怎样才能速成为游戏开发设计师
- 球队-国米
- 提醒
- Ultraedit 使用技巧
- 几个常用的Javascript函数
- 反加班物语
- delphi版怎么变得这么荒凉?一篇Blog也没有
- Invoke methods using System.Reflection
- 如何编写高质量的VB代码(转自天极)(很受用的)
- 用于项目设计的一些网页设计知识
- 罗马数表示整数
- 网页不同分辨率的研究
- 识别客户端分辨率的网页代码(转)