Posted in Javascript onApril 01, 2010
/* * 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 && /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);
基于jquery的获取mouse坐标插件的实现代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@