日期:2014-05-16 浏览次数:20379 次
var rt;
$(window).resize(function(){
clearTimeout(rt);
rt = setTimeout(function(){
alert("执行代码");
},500);
});
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
/* 兼容ie678 */
html,body{height:100%;overflow:visible;}
</style>
<title>test</title>
<script type="text/javascript">
var idt;
var n = 0;
window.onresize = function() {
clearTimeout(idt);
idt = setTimeout(function() {
n++;
document.getElementById('d').innerHTML += n + ',';
}, 10);
}
</script>
</head>
<body>
<div id="d" style="width:1000px;height:1200px;background:#f6f6f6;"></div>
</body>
</html>