基于jquery的获取mouse坐标插件的实现代码_jquery
程序员文章站
2022-05-21 10:45:16
...
复制代码 代码如下:
/*
* Copyright (c) 2010 刘建华
*
* The above copyright notice shall be
* included in all copies or substantial portions of the Software.
* Example:
demo
demo
*/
/*
* mouse Plugin for jQuery
* Version: 1.0
* Release: 2010-03-30
*/
(function($) {
//Main Method
jQuery.mouse = function(e){
var mouseleft = 0;
var mousetop = 0;
if(!($.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent)))
{
mouseleft=e.pageX;
mousetop=e.pageY;
}
else
{
var _top = document.compatMode=="CSS1Compat" ? document.documentElement.scrollTop : document.body.scrollTop;
var _left = document.compatMode=="CSS1Compat" ? document.documentElement.scrollLeft : document.body.scrollLeft;
mouseleft=_left+event.clientX;
mousetop=_top+event.clientY;
}
return {left:mouseleft,top:mousetop} ;
};
})(jQuery);
上一篇: javascript 变态的节点集合_javascript技巧
下一篇: php二维码生成,php