2010-01-20 78 views
0

任何人都可以告诉我为什么我失去了在setTimeout检查的内容萤火虫,我失去了内容,虽然我的内容的高度显示! 欢迎所有回覆!的setTimeout的javascript setTimeout问题

function Tableslide_down(content,height) 
    { 
    var contentID = document.getElementById(content); 
    if(contentID.offsetHeight < height) 
    { 
    contentID.style.top = parseInt(slidingDiv.style.top) + 10 + "px"; 
    setTimeout("Tableslide_down('"+content+"','"+height+"')",10); 
    } 
    contentID.style.display = "block"; 
} 

回答

5
setTimeout(function() { Tableslide_down(content, height); },10); 

第一参数可(MUST)是一个函数。

+1

+1每次从字符串乔恩斯基特杀死构建代码一只小猫。 – slebetman 2010-01-20 19:47:50

0

尝试分配超时给一个变量:

var myto = setTimeout("Tableslide_down('"+content+"','"+height+"')",10); 

这也意味着以后可以清除它,如果你需要:

clearTimeout(myto)