热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

javascriptonmouseout解决办法_javascript技巧

最近在做一个简单的鼠标onmouseover时显示层(层里面有多个链接文字),onmouseout时隐藏层的功能时,发现有诸多问题.
onmouseout 发现它的触发太敏感,当经过层内文字链时,即触发onmousetout事件,功能不能正常显示,经过一番搜索,整理出来,供大家参考。

1、

代码如下:

  


    faddsf  



2、

代码如下:


  var LeaveFunext = function(t,f){for(var p in f){t[p]=f[p]} return t};
  var IE = '\v' == 'v';
  var cOntains= function(wrap,child){
  if(IE) return wrap.contains(child);
  while(child && typeof(child.parentNode) != "undefind"){
  if(wrap == child) return true;
  child = child.parentNode;
}
return false;
  };
  var LeaveFun = function(o){
  var _o = typeof o =="string" ? document.getElementById(o) : o;
  return this == window ? new LeaveFun(_o):LeaveFunext(_o, LeaveFun.prototype);
  };
  LeaveFun.prototype = {
  mouseleave : function(fn){
  if(IE){
  this.attachEvent('onmouseleave',fn);
  }else{
this.addEventListener('mouseout',function(e){
tar = e.relatedTarget;
if(!contains(this, tar)){
fn.call(this);
}
  }, false);
  }
  return this;
  }
  };
  //调用
  LeaveFun('share_customerp').mouseleave(function(){document.getElementById('share_customerp').style.display ='none';})


3、最简单,但在部分系统上会有轻微闪烁。

代码如下:



更多此人的...
留言板
好友


推荐阅读
author-avatar
好几个健康2002_408
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有