linux社区爱心援助Linux认证系列教程业界动态站务新闻公司招聘网络学院网址大全LPI专题CISCO专题
设为首页
加入收藏
管理团队
JSP  
JAVA  
PERL  
 您的位置:首页 > 开发语言 > JavaScript >
栏目导栏
  php
  JSP
  ASP
  asp.net
  JAVA
  c/c++/c#
  perl
  JavaScript
  Basic
  Delphi
资料搜索
热门文章
·javascript 时间对象的格式化
·去掉字符串前后的空格
·javascript 事件监听机制
·javascript 事件调用顺序
·js刷新框架子页面的七种方法
·JavaScript:替换字符串
·IE下的JScript编程需注意的内存
·用javascript操作word文档
·Javascript中CTRL+回车提交表单
·JS 获取鼠标位置
·javascript判断Email地址是否有
·Javascript中Select的OnChange
·JS实现的滑动展开与折叠效果
·有分页功能的WEB打印
·Javascript实现窗口最大化的严
最新文章
·使用CSS改变表格边框样式
·为网页添加浮动广告
·判断表单中添加是否数字的JS与
·让浏览器状态栏动起来
·使用Javascript制作行间颜色间
·禁止用右键查看源代码
·网页侦测四法
·制作弹出公告窗口
·为网页添加特效
·网页中取消鼠标右键方法大全
·JavaScript 根据屏幕解析度显示
·如何实现浏览器上的右键菜单
·如何制作浮动广告
·让弹出窗口变得“体贴”一些
·JavaScript技巧:让网页自动穿上
Google
 
实现Web页面上的右键快捷菜单
[ 作者:  加入时间:2007-11-30 13:11:04  来自:Linux联盟收集整理 ]

样式代码:

<style type="text/css">rWPLinux联盟
   body{font: 9pt "宋体"; margintop: 0px ; color: red; background: #ffffff}rWPLinux联盟
   a.{ font: 9pt "宋体"; cursor: hand; font-size: 9pt ; color: blue; text-decoration: none }rWPLinux联盟
   a:active{ font: 9pt "宋体"; cursor: hand; color: #FF0033 }rWPLinux联盟
   a.cc:hover{ font: 9pt "宋体"; cursor: hand; color: #FF0033}rWPLinux联盟
   .box{ font: 9pt "宋体"; position: absolute; background: LightGrey; }rWPLinux联盟
  </style>

html代码如下:

  <table id="itemopen" class="box" style="DISPLAY:none">rWPLinux联盟
   <tr>rWPLinux联盟
    <td>弹出菜单</td>rWPLinux联盟
   </tr>rWPLinux联盟
   <tr>rWPLinux联盟
    <td><a href="http://blog.csdn.net/Erickson/" class="cc">Erickson的专栏</a></td>rWPLinux联盟
   </tr>rWPLinux联盟
   <tr>rWPLinux联盟
    <td><a href="http://www.csdn.net" class="cc">CSDN</a></td>rWPLinux联盟
   </tr>rWPLinux联盟
   <tr>rWPLinux联盟
    <td><a href="http://www.google.com" class="cc">Google 搜索</a></td>rWPLinux联盟
   </tr>rWPLinux联盟
   <tr>rWPLinux联盟
    <td><a href="http://www.sohu.com" class="cc">搜狐</a></td>rWPLinux联盟
   </tr>rWPLinux联盟
   <tr>rWPLinux联盟
    <td><a href="http://www.yahoo.com" class="cc">Yahoo</a></td>rWPLinux联盟
   </tr>rWPLinux联盟
   <tr>rWPLinux联盟
    <td><a href="http://www.163.com" class="cc">163 网站</a></td>rWPLinux联盟
   </tr>rWPLinux联盟
   <tr>rWPLinux联盟
    <td><a href="http://sports.sina.com.cn" class="cc">新浪网体育</a></td>rWPLinux联盟
   </tr>rWPLinux联盟
   </table>

脚本代码:

右击鼠标显示快捷菜单:rWPLinux联盟
  <script language="JavaScript">rWPLinux联盟
   document.onmousedown = function popUp() {rWPLinux联盟
    menu = document.all.itemopenrWPLinux联盟
    if (event.button == 2) {rWPLinux联盟
    newX = window.event.x + document.body.scrollLeftrWPLinux联盟
    newY = window.event.y + document.body.scrollToprWPLinux联盟
    menu.style.display = ""rWPLinux联盟
    menu.style.pixelLeft = newXrWPLinux联盟
    menu.style.pixelTop = newYrWPLinux联盟
    }rWPLinux联盟
    else if (event.button == 1)rWPLinux联盟
    {rWPLinux联盟
     menu.style.display = "none"rWPLinux联盟
    }rWPLinux联盟
   }rWPLinux联盟
  </script>

屏蔽IE默认的WinForm快捷菜单:rWPLinux联盟
  <script language="JavaScript">rWPLinux联盟
   var message="";rWPLinux联盟
   function clickIE()rWPLinux联盟
   {rWPLinux联盟
    if (document.all)rWPLinux联盟
    {rWPLinux联盟
     (message);rWPLinux联盟
     return false;rWPLinux联盟
    }rWPLinux联盟
   }rWPLinux联盟
   function clickNS(e)rWPLinux联盟
   {rWPLinux联盟
    if (document.layers||(document.getElementById&&!document.all))rWPLinux联盟
    {rWPLinux联盟
     if (e.which==2)rWPLinux联盟
     {rWPLinux联盟
      newX = window.event.x + document.body.scrollLeftrWPLinux联盟
      newY = window.event.y + document.body.scrollToprWPLinux联盟
      menu = document.all.itemopenrWPLinux联盟
      if ( menu.style.display == "")rWPLinux联盟
      {rWPLinux联盟
       menu.style.display = "none"rWPLinux联盟
      }rWPLinux联盟
      elserWPLinux联盟
      {rWPLinux联盟
       menu.style.display = ""rWPLinux联盟
      }rWPLinux联盟
      menu.style.pixelLeft = newXrWPLinux联盟
      menu.style.pixelTop = newYrWPLinux联盟
     }rWPLinux联盟
     if (e.which==3)rWPLinux联盟
     {rWPLinux联盟
      (message);rWPLinux联盟
      return false;rWPLinux联盟
     }rWPLinux联盟
    }rWPLinux联盟
   }rWPLinux联盟
   if (document.layers)rWPLinux联盟
   {rWPLinux联盟
    document.captureEvents(Event.MOUSEDOWN);rWPLinux联盟
    document.onmousedown=clickNS;rWPLinux联盟
   }rWPLinux联盟
   elserWPLinux联盟
   {rWPLinux联盟
    document.onmouseup=clickNS;document.oncontextmenu=clickIE;rWPLinux联盟
   }rWPLinux联盟
   document.oncontextmenu=new Function("return false")rWPLinux联盟
  </script>

Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·调用IE内置打印组件完成web打印方案及例程  (2007-11-30 13:03:54)
 ·巧妙实现隐藏不想打印的web页面元素  (2007-11-30 13:01:57)
 ·webmin--基于Web的 Linux、Unix系统管理工具  (2007-11-29 11:46:03)
 ·web应用程序中的数据库连接  (2007-11-28 13:51:36)
 ·Web Form中的Datagrid的自定义分页  (2007-11-26 16:27:40)
 ·Office Web Components(OWC)绘图控件使用11个问答  (2007-11-26 15:39:01)
 ·好玩的meebo,Web Based IM: 搞定了MSN和Gtalk  (2007-11-24 19:32:20)
 ·有分页功能的WEB打印  (2007-11-23 14:54:40)
 ·Web应用中避免Form重复提交的三种方案  (2007-11-23 14:52:04)
 ·WEB(Javascript)远程调用方案清单  (2007-11-23 14:02:21)