求教javascript里的setTimeout参数传递问题
<script type= "text/javascript " language= "javascript ">
var secs = 10;
var wait = secs * 1000;
var agreetext= " 开始点击 ";
function time_pass()
{
window.open( ' <%=rs( "herf ")%> ');
document.all( 'usetime ').value = agreetext+ "( " + secs + ") ";
document.all( 'usetime ').disabled = true;
for(i = 1; i <= secs; i++) {
window.setTimeout( "update( " + i + ") ", i * 1000);
}
window.setTimeout( "timer() ", wait);
}
function update(num, value) {
if(num == (wait/1000)) {
document.all( 'usetime ').value = agreetext;
} else {
printnr = (wait / 1000)-num;
document.all( 'usetime ').value = agreetext+ "( " + printnr + ") ";
}
}
function timer() {
//document.all( 'usetime ').disabled = false;
document.all( 'usetime ').value = agreetext;
document.all( 'submit2 ').disabled=false;
}
</script>
代码一开始是这样的,都好用,但是,我现在想把secs是传递过来的变量,用一个按钮触发time_pass(),应该如何修改这段代码,望大家指教
------解决方案--------------------function time_pass(secs)
{
var wait = secs * 1000;
再在一个按钮那里加个onclick事件就可以了吧。。。
------解决方案-------------------- <script>
var _st = window.setTimeout;
window.setTimeout = function(fRef, mDelay) {
if(typeof fRef == 'function '){
var argu = Array.prototype.slice.call(argument,2);
var f = (function(){ fRef.apply(null, argu); });
return _st(f, mDelay);
}
return _st(fRef,mDelay);
}
function test(x){
alert(x);
}
window.setTimeout(test,1000, 'fason ');
</script>