日期:2014-05-16 浏览次数:20352 次
var resizeTimer = null;??
?? function doResize()
?? {??
???
??? var screenWidth = document.body.offsetWidth;
??? document.getElementById('frametable').style.left = (screenWidth-990)/2;
????????? resizeTimer=null ;
?? }??
?? window.onresize = function()
?? {??
??? if(resizeTimer==null)
??? {??
????? resizeTimer = setTimeout("doResize()",300);??
??? }??
?? }
?
?
让 onresize 事件只执行一次,默认两次,稍作修改。。。
<script>
var resizeTimer = null;
window.onresize = function(){
?? resizeTimer = resizeTimer ? null : setTimeout(doResize,0);
}
function doResize(){
?? alert('resize');
}
</script>