Created
November 8, 2013 09:29
-
-
Save precious-ming/7368561 to your computer and use it in GitHub Desktop.
js延迟加载
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
a();//页面加载执行a() | |
var i; | |
function a() { | |
alert("1"); | |
i = setTimeout("b()", 3000);//3秒后执行b() | |
} | |
function b() { | |
alert("2"); | |
clearTimeout(i); //清除延时代码 | |
//把所有要要延时后执行的代码都写在b()方法里 | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment