Copy Code code as follows:
$ (function () {
Document.oncontextmenu=function () {return false;} Shielding right button
document.onmousemove=mousemove;//Record mouse position
});
var mx=0,my=0;
function MouseMove (EV) {ev=ev| | Window.event;var mousepos=mousecoords (Ev); mx=mousepos.x;my=mousepos.y;}
function Mousecoords (EV) {
if (ev.pagex| | Ev.pagey) {return{x:ev.pagex,y:ev.pagey};}
return{x:ev.clientx,y:ev.clienty+$ (document). ScrollTop ()};
}
$.fn.extend ({rightmenu:function (id,options) {options = $.extend ({menulist:[]},options); var menucount= Options.menuList.length;
if (!$ ("#" +id) [0]) {
var divmenulist= "<div id=\" "+id+" \ "class=\" div_rightmenu\ "><div><ul class= ' ico ' >";
for (Var i=0;i<menucount;i++) {
divmenulist+= "<li class=\" rmli_ "+options.menulist[i].menuclass+" \ "onclick=\" "+options.menulist[i].clickevent" + ">" +options.menulist[i].menuname+ "</li>";
}
Divmenulist = "</ul></div><div>";
$ (' body '). Append (Divmenulist). Find ("#" +id). Hide (). Find ("Li")
. Bind ("MouseOver", function () {$ (this). addclass ("Rm_mouseover");})
. Bind ("Mouseout", function () {$ (this). Removeclass ("Rm_mouseover");});
$ (document). Click (function () {$ ("#" +id). Hide ();});
}
Return This.each (function () {
This.oncontextmenu=function () {
/* This section determines whether the mouse is moved to the rightmost or bottom side of the page to prevent scroll bars from appearing {* */
var mw=$ (' body '). Width ("), mhh=$ (' html '). Height (), mbh=$ (' body '). Height (),
w=$ (' # ' +id). Width (), h=$ (' # ' +id). Height (),
Mh= (MHH>MBH)? mhh:mbh;//Maximum height compare HTML to body height
if (mhif (mw<w+mx) {mx=mw-w;} Ultra Wide
*/} Of course, you can also skip the * *
$ ("#" +id). Hide (). css ({top:my,left:mx}). Show ();
}
});
}
});
Online Demo Right-click Test effect
Package download