日期:2014-05-18  浏览次数:20442 次

请大家看看,
下面的程序不能循环运行,如果scroller不加参数则可以循环运行,这是为什么
<HTML>
<HEAD>
<div   id=div1> </div1>
<script   language= "javascript ">
var   i=1;
var   handle;
function   scroller(ddd)
{
alert(ddd);
handle=setTimeout( "scroller(ddd); ",2000);

}
function   stop()
{
clearTimeout(handle);
}


</script>
</HEAD>
<body>
<input   type= "button "   value= "ok "   onclick= "scroller( '你好 ') ">
<input   type= "button "   value= "ok "   onclick= "stop() ">
</body>
</HTML>

------解决方案--------------------
handle=setTimeout( "scroller( 'ddd '); ",2000);
------解决方案--------------------
修改成:
<HTML>
<HEAD>
<script language= "javascript ">
var i=1;
var handle;
var ddd;
function scroller(ddd)
{
var ddd= "你好! ";
alert(ddd);
handle=setTimeout( "scroller(ddd); ",2000);
}
function stop()
{
clearTimeout(handle);
}
</script>
</HEAD>
<body>
<input type= "button " value= "ok " onclick= "scroller( '你好 ') ">
<input type= "button " value= "ok " onclick= "stop() ">
</body>
</HTML>
这个看看。
问题出在 没有定义 ddd