也许你也遇到过这样的问题,或者还没注意到有过这样的问题,如下代码,在窗口发生变化时,会进入死循环:

var _funResize = function(){
console.log('resize...' + Math.random());
}
$(window).bind('resize',_funResize);

是问题,总得研究解决,方案:

var _funResize = function(){
// 先解除绑定
$(window).unbind('resize',_funResize); console.log('resize...' + Math.random()); // 重新绑定
setTimeout(function(){
$(window).bind('resize',_funResize);
},);
}
$(window).bind('resize',_funResize);

但是这种方法只能是触发第一次resize事件,有时我们是想触发最后一次resize事件。可以通过时间来判断

        var rtime = new Date();
var timeout = false;
var delta = ;
$(window).resize(function() {
rtime = new Date();
if (timeout === false) {
timeout = true;
setTimeout(resizeend, delta);
}
}); function resizeend() {
if (new Date() - rtime < delta) {
setTimeout(resizeend, delta);
} else {
timeout = false;
alert($(window).height());
}
}

最新文章

  1. innobackupex 重启MySQL
  2. 50.ISE布局布线错误
  3. 关于insertBefore
  4. LSJ_NHibernate第一章 NHibernate介绍
  5. asp.net:验证控件中ValidationExpression的写法
  6. linux系统下安装apache与tomcat
  7. ECSHOP商城全站自定义TITLE标题设置
  8. cocos2d-x3.2中map的基本操作和使用
  9. if(){}else 语句的正确写法以及它的嵌套使用
  10. python爬去电影天堂恐怖片+游戏
  11. 3DES加密
  12. [USACO08JAN]跑步Running
  13. Ubuntu全盘备份与恢复,亲自总结,实测可靠
  14. 常见六大Web安全攻防解析
  15. FTP:mget匹配文件名后下载
  16. ansible 剧本
  17. ThinkPHP5.0 实现 app微信支付功能
  18. Structured Streaming教程(2) —— 常用输入与输出
  19. webstocket 聊天
  20. mybatis批量更新update-设置多个字段值 报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

热门文章

  1. php重修
  2. 堆栈C实现
  3. Linux环境下使用C/C++编写CGI(httpd)
  4. wp8 入门到精通 启动系统分享照片任务
  5. Windows下Apache服务器中自动配置二级子域名
  6. Effective C++ 之 0 导读(Introduction)
  7. GitHub 使用教程图文详解(转)
  8. 在Asp.Net MVC中用Ajax回调后台方法
  9. UML九种图详解-外链
  10. MIT 6.828 JOS学习笔记2. Lab 1 Part 1.2: PC bootstrap