window.onload = picChangePrepare;
function picChangePrepare()
{
var gallery = document.getElementById("pic");
var images = gallery.getElementsByTagName("img");
showPic(images);/*希望传递一个对象数组*/
}
function showPic(images)
{
change_1 = window.setTimeout(showPic_1(),1000,images);
}
function showPic_1(images)
{
alert(typeof images);
}
var __sto = setTimeout;
window.setTimeout = function(callback,timeout,param)
{
var args = Array.prototype.slice.call(arguments,2);
var _cb = function()
{
callback.apply(null,args);
}
__sto(_cb,timeout);
}
运行后alert()直接显示images未定义。最后一个setTimeout函数改写在网上拷贝的,我不太懂。我只希望最后能成功传递一个对象数组就行。希望有人细说下怎样做,能解释下原因更好。
|