Click to See Complete Forum and Search --> : splice() and w2k am I crazy
mikehd
03-24-2003, 04:00 PM
Am I nuts or just freaking out. This splice code dosen't work on IE6 (with all current service packs)in w2K:
cars = ["Mercedes", "Ford", "Chrysler", "Honda", "Volvo"]
document.write(cars.splice(1,2));
I am using XP and no problem, then I test on a w2k machine and I get an error!
I have different OS's.
laptop w2k - it works
tower 98 - it works
tower XP - it works
tower NT - it works
tower w2k pro - same javascript error
Am I missing something???
Any help on this will be appreciated by me and my sanity.
khalidali63
03-24-2003, 04:09 PM
Whats the error....
?
Khalid
mikehd
03-24-2003, 05:00 PM
The error is :
Object dosen't support this method or property
I did find this work around that looks for the prototype and if it is undefined, runs the function. Works on w2k
function Array_splice(index, delTotal) {
var temp = new Array()
var response = new Array()
var A_s = 0
for (A_s = 0; A_s < index; A_s++) {
temp[temp.length] = this[A_s]
}
for (A_s = 2; A_s < arguments.length; A_s++) {
temp[temp.length] = arguments[A_s]
}
for (A_s = index + delTotal; A_s < this.length; A_s++) {
temp[temp.length] = this[A_s]
}
for (A_s = 0; A_s < delTotal; A_s++) {
response[A_s] = this[index + A_s]
}
this.length = 0
for (A_s = 0; A_s < temp.length; A_s++) {
this[this.length] = temp[A_s]
}
return response
}
if (typeof Array.prototype.splice == "undefined") {
Array.prototype.splice = Array_splice
}
Still don't understand why it works on the laptop w2k and not on my other w2k OS, but using this workaround I have found my sanity.
khalidali63
03-24-2003, 07:02 PM
Yep...something is for sure wrong on your win2k machine.cus I have win2k sp2 NS6+/IE6+ and it splice works..
Cheers
Khalid
mikehd
03-25-2003, 08:33 AM
The odd thing is that I have two different computers with w2k and it dosen't work on either, but the above mentioned code does.
Anyway, thanks for the response