日期:2014-05-16  浏览次数:20497 次

高手进,关于js事件
我正在做一个网页版的即时通讯,现在有个问题,请大家帮忙解决一下。
您看到图片了吧,我现在的问题是这样的。当鼠标移动到联系人头像的时候,在提示通讯的左侧显示个人信息,可是我的即时通讯是通过iframe加载的,我用parent可以实现个人信息显示,但是当鼠标移出iframe的时候,个人信息就会消失,于是我想用推迟响应时间,并在父页面中通过判断event的target是不是个人信息那个div来实现移动到个人信息不消失,可是经过hoverDelay后,event消失了,hoverDelay.js的代码是这样的。
(function($){
  $.fn.hoverDelay = function(options){
  var defaults = {
  hoverDuring: 200,
  outDuring: 200,
  hoverEvent: function(){
  $.noop();
  },
  outEvent: function(){
  $.noop();
  }
  };
  var sets = $.extend(defaults,options || {});
  var hoverTimer, outTimer;
  return $(this).each(function(){
  $(this).hover(function(){
  clearTimeout(outTimer);
  hoverTimer = setTimeout(sets.hoverEvent, sets.hoverDuring);
  },function(){
  clearTimeout(hoverTimer);
  outTimer = setTimeout(sets.outEvent, sets.outDuring);
  });
  });
  }
})(jQuery);

我想知道,怎么能够保存住这个event对象啊?

------解决方案--------------------
先用 event 判断,在setTimeout 设置隐藏