在某个时间段如果多次触发resize事件,执行最后一次
var _this = this;
var resizeTimer = null;
$(window).bind('resize', function () {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(function(){
console.log(_this.idbase);
if ($('#' + _this.idbase + '_mask').length >= 1) {
console.log($(document.body).width());
$('#' + _this.idbase + '_mask').width($(document.body).width());
$('#' + _this.idbase + '_mask').height($(document).height());
$('#' + _this.idbase + '_mask').show();
};
} , 500);
});插件方法参照:http://blog.csdn.net/kmblack1/article/details/8799491
本文介绍了一种使用JavaScript实现的窗口调整大小事件处理方法,通过设置延时来避免短时间内多次触发事件导致的性能问题,确保只执行最后一次调整,并更新了遮罩层的宽度和高度。
1339

被折叠的 条评论
为什么被折叠?



