日期:2014-05-17 浏览次数:20652 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="jquery-1.4.4.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { var mouseX; var mouseY; $(document).bind("contextmenu", function (e) { //去掉默认右键功能 return false; }); $(document).mousedown(function (e) { mouseX = event.clientX; mouseY = event.clientY; if (3 == e.which) { //右键单击 $("#area").css('margin-left', mouseX); $("#area").css('margin-top', mouseY); $("#area").show(); } else if (1 == e.which) { //左键单击 $("#area").hide(); } }) }) </script> </head> <body> <form id="form1" runat="server"> <div> <div id="area" style="width:150px; height:200px; background-color:red; display:none;" > <input type="button" value="我是按钮" onmousedown="alert('11');" /> </div> </div> </form> </body> </html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function () { var mouseX; var mouseY; $(document).bind("contextmenu", function (e) { //去掉默认右键功能 return false; }); $(document).mousedown(function (e) { mouseX = e.clientX; mouseY = e.clientY; if (3 == e.which) { //右键单击 $("#area").css('margin-left', mouseX); $("#area").css('margin-top', mouseY); $("#area").show(); } else if (1 == e.which && !( $('#area').find(e.target).length != 0 || $('#area')[0] == $(e.target)[0])) { //左键单击 $("#area").hide(); } return }) }) </script> </head> <body> <form id="form1" runat="server"> <div> <div id="area" style="width:150px; height:200px; background-color:red; display:none;" > <input type="button" value="我是按钮" onmousedown="alert('11');" /> </div> </div> </form> </body> </html>