基于jquery的获取mouse坐标插件的实现代码
作者:bea
代码如下: /* * Copyright (c) 2010 刘建华 * * The above copyright notice shall be * included in all copies or substantial portions of the Software. * Example: <div style="height:1000px">demo</div> <div id="demo" style="heigh
代码如下:
/*
* Copyright (c) 2010 刘建华
*
* The above copyright notice shall be
* included in all copies or substantial portions of the Software.
* Example:
<div style="height:1000px">demo</div>
<div id="demo" style="height:50px; background:purple; width:50px;z-index:999999; position:absolute;left:-1000px;top:-1000px;">demo</div>
<script type="text/javascript" >
var o = $(document);
o.mousemove( function(e){
var d = document.getElementById("demo");
d.style.left = ($.mouse(e).left + 5) + "px";
d.style.top = ($.mouse(e).top + 5) + "px";
});
</script>
*/
/*
* 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 && /MSIEs(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);
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- jquery select下拉框操作的一些说明
- 纯JavaScript实现的完美渐变弹出层效果代码
- AJAX使用了UpdatePanel后无法使用alert弹出脚本
- 获取焦点时,利用js定时器设定时间执行动作
- Javascript 类与静态类的实现(续)
- 用js实现计算加载页面所用的时间
- 捕获input文本框内容改变事件的js代码
- Extjs Ext.MessageBox.confirm 确认对话框详解
- ExtJS Ext.MessageBox.alert()弹出对话框详解
- Extjs列表详细信息窗口新建后自动加载解决方法
- JavaScript 一行代码,轻松搞定浮动快捷留言-V2升级版
- 可以测试javascript运行效果的代码
- js 刷新页面的代码小结 推荐
- javascript 打字游戏实现代码
- JQuery 插件制作实践 xMarquee插件V1.0
- Jquery 插件学习实例1 插件制作说明与tableUI优化
- jquery ui 1.7 ui.tabs 动态添加与关闭(按钮关闭+双击关闭)
- 初试jQuery EasyUI 使用介绍
- 跟我一起学写jQuery插件开发方法(附完整实例及下载)