等頁(yè)面加載完再加載js 頁(yè)面加載完成后等待一段時(shí)間在執(zhí)行js的方法,時(shí)間如何設(shè)定?
頁(yè)面加載完成后等待一段時(shí)間在執(zhí)行js的方法,時(shí)間如何設(shè)定?例如:function test(){return 1}頁(yè)面加載完成事件:window.onload文件=Function(){setTime
頁(yè)面加載完成后等待一段時(shí)間在執(zhí)行js的方法,時(shí)間如何設(shè)定?
例如:function test(){return 1}頁(yè)面加載完成事件:window.onload文件=Function(){setTimeout(test,1000)//1000ms=executetestmethodafter1second}如果使用jQuery,可以:$(window)。Load(function(){SetTimeout(test,1000)//1000 ms=execute the test method after 1秒})SetTimeout只執(zhí)行一次并重復(fù)執(zhí)行setIntervalwindow.onload=Function(){setinterval(test,1000)//1000ms=1s,每隔1s執(zhí)行一次test方法}