鼠标插入/离开处理程序

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鼠标插入/离开处理程序相关的知识,希望对你有一定的参考价值。

These functions allow you to easily set a handler for a virtual mouseleave/enter event.

This requires my [MouseBoundaryCrossing](http://snipplr.com/view/8206/crossbrowser-mouseenterleave-solution/) class.
  1. /****************************************
  2. These functions allow you to easily set a handler for a virtual mouseleave/enter event, using my MouseBoundaryCrossing class.
  3. /****************************************/
  4.  
  5. //Note that a mouseout/over event is always fired before a mouseleave/enter event
  6. //Also note that mouseleave/enter events do not bubble; effectively, they don't bubble in this implementation either.
  7. //usage: elem.onmouseout = onMouseLeave(leaveHandler, outHandler);
  8. //usage: elem.onmouseover = onMouseEnter(enterHandler, overHandler);
  9. function onMouseLeave(handleLeave, handleOut)
  10. {
  11. if(!handleLeave) return handleOut;
  12. return function(evt)
  13. {
  14. evt = evt || window.event;
  15. if(handleOut) handleOut.call(this, evt);
  16. try{
  17. var mbc = new MouseBoundaryCrossing(evt, this);
  18. if(mbc.leftLandmark) handleLeave.call(this, evt);
  19. }catch(e){}
  20. }
  21. }
  22. function onMouseEnter(handleEnter, handleOver)
  23. {
  24. if(!handleEnter) return handleOver;
  25. return function(evt)
  26. {
  27. evt = evt || window.event;
  28. if(handleOver) handleOver.call(this, evt);
  29. try{
  30. var mbc = new MouseBoundaryCrossing(evt, this);
  31. if(mbc.enteredLandmark) handleEnter.call(this, evt);
  32. }catch(e){}
  33. }
  34. }

以上是关于鼠标插入/离开处理程序的主要内容,如果未能解决你的问题,请参考以下文章

C# winfrom程序 dev控件 gridview实现鼠标悬浮变色,离开颜色恢复

android - 离开应用程序时保持谷歌地图片段在位置上放大

QT学习之事件处理

js代码实现鼠标移动到上面一个效果,鼠标离开效果保持

[ jquery 文档处理 insertBefore(content) before(content|fn) ] 此方法用于把所有匹配的元素插入到另一个指定的元素元素集合的前面,实现外部插入(代码片段

如何用js判断鼠标离开当前页面