HTML5怎样推迟一个函数的执行?

<html>
function a() 
{ alert("aa"); }
function b()
{ a(); }
<body onloud="b()"></body>
</html>
退出a()函数的执行!

HUWWW
浏览 1000回答 4
4回答

慕容3067478

  1.[self performSelector:@selector(函数名) withObject:nil afterDelay:5.0f]  条件:在uiviewController的主线程中  2.[NSTimerscheduledTimerWithTimeInterval:5.0f target:self selector:@selector(函数名) userInfo:nil repeats:NO];在具体函数中,执行代码,执行完毕以后调用NSTimer invalidate方法来销毁timer  3.[NSThread sleepForTimeInterval:5.0f];[要延迟执行的方法];  条件:主线程或者子线程都可

犯罪嫌疑人X

<html>function a(){ alert("aa"); }function b(){ a(); }<body onload="window.setTimeout(b,5000);"></body></html>

郎朗坤

function a(){ alert("aa"); }function b(){ setTimeout(a(),延迟时间); }<body onloud="b()"></body>

一只萌萌小番薯

用async或者是defer这种HTML5新标签可以延迟加载函数
打开App,查看更多内容
随时随地看视频慕课网APP