请问:怎么使setInterval("fun()", 200)中的fun()能传递参数吗?改怎么写
setInterval(fun, 200,parameter1,....parameterN)网上找的这种传参方法得到的是undefind
本身可以传递参数
setInterval("fun(" + 1 + ")", 200)
只是传不了对象,如果需要传对象:
/**
调用
cusSetInterval(f, 1000, param1, param2);
这种可以用我提交的扩展方法
cusSetInterval(fun, 200, 1, 2, 3);
如果是数字或字符串可以
setInterval("f(" + 1 + "," + 2 + ")", 1000);
测试通过,应该是你哪里写得有问题
[code="java"]
<br> <!--<br> /**定时刷新*/ <br> function refreshPark(pIndex,type,searchRange,search,searchContent) <br> { <br> setInterval("getPark("+pIndex+","+type+","+searchRange+","+search+","+searchContent+")",1000); <br> }</p> <pre><code>function getPark(pIndex,type,searchRange,search,searchContent) { var mydiv = document.getElementById("mydiv"); mydiv.innerHTML += "<br>" + pIndex+","+type+","+searchRange+","+search+","+searchContent; } refreshPark(1,2,3,4,5); </code></pre> <p>//--><br>