好CODE逻辑很复杂看的我云里雾里的。。这东西不错
<html>
<script language="javascript">
var timef
var eventList;
function Pause(obj)
{
eventList=obj;
//GoOn(); //方法一
timef=setTimeout("GoOn()",1000); //方法二
}function GoOn()
{
if (eventList.NextStep)
{
var flag=document.getElementById("flag").value;
if(flag=="1")
{
window.NextStep();
}
else {
setTimeout(GoOn,1000);
}
}
}
function Test()
{
alert("hellow");
Pause(this);//调用暂停函数
this.NextStep=function()
{
alert("NextStep");
}
}
function reTest()
{
document.getElementById("flag").value="1";
}
</script>
<body><input type="button" value="开始" onclick='Test();'/>
<input type="button" value="继续" onclick='reTest();'/>
<input type="test" id="flag"/>
</body>
</html>
<html>
<script language="javascript">
var timef
var eventList;
function Pause(obj)
{
eventList=obj;
//GoOn(); //方法一
timef=setTimeout("GoOn()",1000); //方法二
}function GoOn()
{
if (eventList.NextStep)
{
var flag=document.getElementById("flag").value;
if(flag=="1")
{
window.NextStep();
}
else {
setTimeout(GoOn,1000);
}
}
}
function Test()
{
alert("hellow");
Pause(this);//调用暂停函数
this.NextStep=function()
{
alert("NextStep");
}
}
function reTest()
{
document.getElementById("flag").value="1";
}
</script>
<body><input type="button" value="开始" onclick='Test();'/>
<input type="button" value="继续" onclick='reTest();'/>
<input type="test" id="flag"/>
</body>
</html>
if(typeof eventList.NextStep == "function"){
...
eventList.NextStep();
}
2.
setTimeout("GoOn()",1000)相当于setTimeout(GoOn,1000)
文档里第一个参数的解释是:Variant that specifies the function pointer or string that indicates the code to be executed when the specified interval has elapsed.
如果换一下位置:
function Test()
{
this.NextStep=function()
{
alert("NextStep");
}
Pause(this);//调用暂停函数}
方法一一样可以使用.
http://bbs.51js.com/viewthread.php?tid=66361&highlight=%D4%DD%CD%A3