jquery实现右键菜单
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery自定义区域的鼠标右键菜单</title>
<style type="text/css">
#mask{position: absolute;left: 0;top: 0;z-index: 9000;display: block;}
#myMenu{position: absolute;display: none;z-index: 9999;background: yellow;border: 1px solid;width: 200px;height: 155px;}
#textbox{background: orange;width: 380px;border: 2px solid;}
img{height: 30px;width: 30px;}
td{font-size: 20px;cursor: pointer;}
a{text-decoration: none;color: black;}
a:hover{color: white;background: black;}
</style>
<script type="text/javascript" src="../js/jquery-3.1.1.js"></script>
<script type="text/javascript">
var windowwidth;
var windowheight;
var checkmenu;
$(window).ready(function() {
$('#myMenu').hide();
$('#textbox').on("contextmenu",function(e){
windowwidth = $(window).width();
windowheight = $(window).height();
checkmenu = 1;
$('#mask').css({
'height': windowheight,
'width': windowwidth
});
$('#myMenu').show(500);
$('#myMenu').css({
'top':e.pageY+'px',
'left':e.pageX+'px'
});
return false;
});
$('#mask').click(function(){
$(this).height(0);
$(this).width(0);
$('#myMenu').hide(500);
checkmenu = 0;
return false;
});
$('#mask').on("contextmenu",function(){
$(this).height(0);
$(this).width(0);
$('#myMenu').hide(500);
checkmenu = 0;
return false;
});
$(window).resize(function(){
if(checkmenu == 1) {
windowwidth = $(window).width();
windowheight = $(window).height();
$('#mask').css({
'height': windowheight,
'width': windowwidth,
});
}
});
});
</script>
</head>
<body>
<div id="myMenu" >
<table cellspace="3">
<tr>
<td ><img src="data:images/twitter.png" ></td><td><a href="#">tweet me</a></td>
</tr>
<tr>
<td ><img src="data:images/facebook.png" > </td><td><a href="#">facebook share</a></td>
</tr>
<tr>
<td ><img src="data:images/myspace.png" > </td><td><a href="#">myspace share</a></td>
</tr>
<tr>
<td ><img src="data:images/mail.png" > </td><td><a href="#">e-mail this</a></td>
</tr>
</table>
</div>
<div id="mask"> </div>
<div id="textbox">
<p>嗨!您好,在这个区域内点击您的鼠标右键吧,会弹出一个自定义的右键菜单,和浏览器的右键菜单完全不一样哦!<p/>
</div>
</body>
</html>
jquery实现右键菜单的更多相关文章
- 用jQuery修改右键菜单
概述 以前在网上找过屏蔽右键菜单的代码,也找过屏蔽F12的代码,今天无意之中看到别人的右键菜单很有意思,我也想来搞一个. 思路 建立一个菜单并且隐藏起来. 用window.oncontextmenu屏 ...
- [xPlugins] jQuery Contextmenu右键菜单
[2012-04-12] Contextmenu 右键菜单 v0.1 版本发布 [功能] 在特定区域弹出右键菜单 [功能] 可以在弹出右键菜单区域内,再屏蔽某个小区域. [功能] 有两种方式添加右键菜 ...
- jQuery EasyUI 右键菜单--关闭标签/选项卡
目录结构: noContextMenu.js 文件内容如下: $(function(){ //屏蔽右键菜单 $(document).bind("contextmenu", func ...
- jquery 自定义右键菜单
如果要自定义右键菜单,那么就需要禁止原本的右键菜单,代码如下 document.oncontextmenu = new Function("return false;");//禁止 ...
- 实现JQuery EasyUI右键菜单变灰不可用效果
使用过EasyUI的朋友想必都知道疯狂秀才写的后台界面吧,作为一个初学者我不敢妄自评论它的好坏,不过它确实给我们提供了一个很好框架,只要在它的基础上进行修改,基本上都可以满足我们开发的需要. 知道“疯 ...
- jQuery自定义右键菜单
首先看下效果,效果在最下面: 代码: body { font-size: 12px; margin: 0px; padding: 0px; } form,div,ul,li { margin: 0px ...
- (转)jQuery禁止右键菜单,全选
本文转载自:http://www.cnblogs.com/lucker/archive/2012/09/21/2696464.html $("body").bind("c ...
- Jquery 右键菜单(ContextMenu)插件使用记录
目前做的项目需要在页面里面用右键菜单,在网上找到两种jquery的右键菜单插件,但是都有各种问题.所以就自己动手把两种插件结合了下. 修改后的右键菜单插架可以根据绑定的触发页面元素不同,复用同一个菜单 ...
- jQuery右键菜单contextMenu实例
URL: http://www.cnblogs.com/whitewolf/archive/2011/09/28/2194795.html http://www.blogjava.net/superc ...
随机推荐
- JS模块化开发(一)——seaJs
模块化开发要解决的问题: 1.冲突 比如:多人协作开发时,不同js库中的函数重名问题 可以用命名空间解决: var module={} module.a=1; module.b=function(){ ...
- Angular组件生命周期钩子
Angular会按以下顺序依次调用以下钩子(8个): ngOnChanges ngOnInit ngDoCheck ngAfterContentInit ngAfterContentChecked n ...
- Python Machine Learning-Chapter3
Chapter 3:A Tour of Machine Learning Classifiers Using Scikit-learn 3.1:Training a perceptron via sc ...
- MySQL_help语句(不定时更新)
1.使用delimiter 命令重新定义mysql 的默认语句分隔符 delimiter $
- 怎么看SQL表里某列是否是自增列
开启或关闭自增列 SET IDENTITY_INSERT 表名 ON/OFF 1.语句 Select OBJECTPROPERTY(OBJECT_ID('表名'),'TableHasIdentity' ...
- ruby计算完成率
task_complete = ((task_forms_w.to_f / task_forms_num.to_f)*100).round(2).to_s << "%" ...
- contourf和contour用法区别
import numpy as np import matplotlib.pyplot as plt %matplotlib inline from matplotlib.colors import ...
- 小程序Promise不支持finally解决方案
小程序Promise不支持finally解决方案 代码片段 点击链接即可在微信开发者工具中查看代码wechatide://minicode/t2eidemj7P3X git地址 基本思路 小程序的Pr ...
- Linux - 系统资源
查看剩余内存 free -m #-/+ buffers/cache: #6458M为真实使用内存 1649M为真实剩余内存(剩余内存+缓存+缓冲器) #linux会利用所有的剩余内存作为缓存,所以要保 ...
- luogu P1268 树的重量
一开始把这题想复杂了,,, 这里记\(di[i][j]\)表示\(i\)到\(j\)的距离 首先如果\(n=2\),答案显然为\(di[1][2]\) 如果\(n=3\) 懒得画图了盗图过来 那么3号 ...