首页 >web前端 >js教程 >基于jquery的获取mouse坐标插件的实现代码_jquery

基于jquery的获取mouse坐标插件的实现代码_jquery

WBOY
WBOY原创
2016-05-16 18:30:35953浏览

复制代码 代码如下:

/*
* 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);
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn