添加IE右键菜单

菜单

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>自定义鼠标右键弹出式菜单</title>
<style type="text/css">
<!--
.div1 { border-top:buttonface 1px solid;border-left:buttonface 1px solid;border-bottom:windowframe 1px solid;border-right:windowframe 1px solid;}
.div2 { border-top:window 1px solid;border-left:window 1px solid;border-bottom:buttonshadow 1px solid;border-right:buttonshadow 1px solid;}
.MouseOver {background-color:highlight;color:highlighttext;font-size: 12px;cursor:hand;font-size: 12px;}
.MouseOut {background-color:buttonface;color:buttontext;font-size: 12px;cursor:default;font-size: 12px;}
-->
</style>
<script language="javascript">
//弹出菜单
function PopupMouseRightButtonUpMenu()
{
//显示菜单
 if(MouseMenu.style.visibility=='visible') MouseMenu.style.visibility='hidden';
//如果是链接、文本区或输入框,则显示IE菜单
 if (event.srcElement.tagName=='A' || event.srcElement.tagName=='TEXTAREA' || event.srcElement.tagName=='INPUT' || document.selection.type!='None')
    return true;
 else
    {
    //防止菜单出格
     if (event.clientX+150 > document.body.clientWidth) MouseMenu.style.left=event.clientX+document.body.scrollLeft-150;
     else MouseMenu.style.left=event.clientX+document.body.scrollLeft;
     if (event.clientY+DivH > document.body.clientHeight) MouseMenu.style.top=event.clientY+document.body.scrollTop-DivH;
     else MouseMenu.style.top=event.clientY+document.body.scrollTop;
     MouseMenu.style.visibility='visible';
    }
//禁止IE菜单
return false;
}
//画出菜单,但不显示
function DrawMouseRightButtonUpMenu(){
DivH=2;
//oSelection = document.selection;
var HrStr='<tr><td align=\"center\" valign=\"middle\" height=\"2\"><TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"128\" height=\"2\"><tr><td height=\"1\" bgcolor=\"buttonshadow\"><\/td><\/tr><tr><td height=\"1\" bgcolor=\"buttonhighlight\"><\/td><\/tr><\/TABLE><\/td><\/tr>';
var MenuItemStr1='<tr><td align=\"center\" valign=\"middle\" height=\"20\"><TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"132\"><tr><td valign=\"middle\" height=\"16\" class=\"MouseOut\" onMouseOver=\"this.className=\'MouseOver\'\" onMouseOut=\"this.className=\'MouseOut\'\" onclick=\"'
var MenuItemStr2="<\/td><\/tr><\/TABLE><\/td><\/tr>";
var historyMenu=['window.history.back()\">后退','window.history.forward()\">前进'];
var SysMenu=['\">查找 <INPUT TYPE=\"text\" Size=\"10\" onkeypress=\"if (event.keyCode == 13) {MouseMenu.style.visibility=\'hidden\';var temp = this.value; this.value = \'\';return findInPage(temp)}\";\'>',
             'document.execCommand(\'SelectAll\')\">全选',
             'MouseMenu.style.visibility=\'hidden\';document.execCommand(\'SaveAs\',\'true\')\">另存为 ',
             'location.replace(\'view-source:\'+location.href)\">查看源文件',
             'MouseMenu.style.visibility=\'hidden\';window.print()\">打印',
             'window.location.reload()\">刷新'];

var MenuStr='';
for(i=0;i<historyMenu.length;i++)
   {
    MenuStr+=MenuItemStr1+historyMenu[i]+MenuItemStr2;
    DivH+=20;
   }
MenuStr+=HrStr;
for(i=0;i<arguments.length;i++)
   {
    MenuStr+=MenuItemStr1+arguments[i]+MenuItemStr2;
    DivH+=20;
   }

if(arguments.length>0)
  {
   MenuStr+=HrStr;
   DivH+=2;
  }

for(i=0;i<SysMenu.length;i++)
   {
    MenuStr+=MenuItemStr1+SysMenu[i]+MenuItemStr2;
    DivH+=20;
   }

var aboutMenu=['MouseMenu.style.visibility=\'hidden\';alert(\'http:\/\/www.cnblogs.com\\nmailto:terry_52#163.net\')">关于 ']
MenuStr+=HrStr;
for(i=0;i<aboutMenu.length;i++)
   {
    MenuStr+=MenuItemStr1+aboutMenu[i]+MenuItemStr2;
    DivH+=20;
   }

var MenuTop = '<DIV id=\"MouseMenu\" class=\"div1\" style=\"position:absolute; left:0px; top:0px; width=150;height='+DivH+'; z-index:1; visibility:hidden;\">\n' +
             '<TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"div2\">\n' +
             '<tr>\n' +
             '<td bgcolor=\"' + MenuBarColor+ '\" width=\"50\" valign=\"bottom\" align=\"center\"  bgcolor=\"buttonface\">\n' +
             '<\/td>\n'+
             '<td bgcolor=\"buttonface\">\n'+
             '<TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"0\">';
var MenuBottom = '<\/TABLE><\/td><\/tr><\/TABLE><\/DIV>';
document.write(MenuTop+MenuStr+MenuBottom);
//prompt('aa',MenuTop+MenuStr+MenuBottom)
document.body.oncontextmenu=new Function('return PopupMouseRightButtonUpMenu();');
document.body.onclick=new Function('if(event.srcElement.tagName !=\'INPUT\') MouseMenu.style.visibility=\'hidden\'');
document.body.onscroll=new Function('MouseMenu.style.visibility=\'hidden\';');
document.body.onselectstart=new Function('MouseMenu.style.visibility=\'hidden\';');
window.onresizestart=new Function('MouseMenu.style.visibility=\'hidden\';');
}
var NS4 = (document.layers);
var IE4 = (document.all);
var win = window;
var n = 0;
//查找字符串
function findInPage(str) {
  var txt, i, found;
  if (str == '')
    return false;
  if (NS4) {
    if (!win.find(str))
      while(win.find(str, false, true))
        n++;
    else
      n++;
    if (n == 0)
      alert('文档搜索完毕。');
  }
  if (IE4) {
    txt = win.document.body.createTextRange();
    for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
      txt.moveStart('character', 1);
      txt.moveEnd('textedit');
    }
    if (found) {
      txt.moveStart('character', -1);
      txt.findText(str);
      txt.select();
      txt.scrollIntoView();
      n++;
    }
    else {
      if (n > 0) {
        n = 0;
        findInPage(str);
      }
      else
        alert('文档搜索完毕。');
    }
  }
  return false;
}
</script>
</head>
<body>
自定义鼠标右键弹出式菜单
<a href=http://www.xrss.cn>网络大本营</a>
<SCRIPT LANGUAGE="JavaScript">
<!--
var MenuBarColor ='#6600FF';
DrawMouseRightButtonUpMenu();
//-->
</SCRIPT>
</body>
</html>

时间: 2024-08-24 08:07:32

添加IE右键菜单的相关文章

Win8系统将蓝牙添加到右键菜单“发送到”选项的方法

  Win8系统将蓝牙添加到右键菜单"发送到"选项的方法 1.打开C:WindowsSystem32,搜索fsquirt.exe,这时会得到多个搜索结果,选择路径是C:WindowsSystem32的那个,其他的也可以,只不过是英文罢了. 2.在fsquirt.exe上右键->创建快捷方式,因为无法在当前位置创建快捷方式,所以点"是"把快捷方式放在桌面上; 3.在开始屏幕直接输入shell:sendto.然后点击输入框下面出现的shell:sendto; 4.

将Windows Defender添加到右键菜单的方法教程

  熟悉Windows Defender的用户都知道,Windows Defender不仅是一款简单的防间谍软件,同时该软件也是非常强大的windows系统杀毒软件,软件主要分为完全扫描.快速扫描.自定义扫描以及自动实时监控功能,用户在win10系统下安装该软件后,系统就无需再安装第三方杀毒软件了,不过有部分用户向将Windows Defender添加到右键菜单中,方便对指定文件进行查杀,故此小编为大家带来了Windows Defender扫描选项添加到Win10右键菜单中方法,有需要的用户不妨

Win 7将显示隐藏文件的命令添加进右键菜单

  有朋友在求助区问如何添加"显示隐藏文件和系统文件"到右键菜单,恰好搜到了方法,拿出来共享一下,希望对有需要的朋友有帮助. 方法很简单, Step 1 打开记事本,将下面的代码拷贝进去:Dim WSHShell Set WSHShell = WScript.CreateObject("WScript.Shell") sTitle1 = "SSH=0" sTitle2 = "SSH=1" if WSHShell.RegRead

C# 系统应用之ListView控件 (三).添加ContextMenuStrip右键菜单打开删除文件

        在前面讲述过使用TreeView控件和ListView控件显示磁盘目录信息,但仅仅是显示信息是不够的,我们还需要具体的操作.在"个人电脑使用历史痕迹"项目中我还需要添加"打开文件"和"删除文件"两种方法.具体如下:         在第一篇文章"C# 系统应用之TreeView控件 (一).显示树状磁盘文件目录及加载图标"中显示如下:         http://blog.csdn.net/eastmount

将Word页面设置添加进右键菜单

在平时使用Word编辑.打印文件时常会用到"页面设置"命令,最通常的操作方法是:执行"文件→页面设置"菜单命令.其实,我们完全可以将Word的"页面设置"命令放进Word右键菜单,这样可以给操作带来很大的方便. 首先,打开Word,执行"工具→自定义"菜单命令,在弹出的"自定义"对话框中,单击"工具栏"选项卡,在其下的下拉列表框中选择"快捷菜单"选项. 此时,屏幕上便

轻松将Word页面设置添加进右键菜单

我们在平时使用Word编辑.打印文件时常会用到"页面设置"命令,最通常的操作方法是:执行"文件→页面设置"菜单命令.其实,我们完全可以将Word的"页面设置"命令放进Word右键菜单,这样可以给操作带来很大的方便. 首先,打开Word,执行"工具→自定义"菜单命令,在弹出的"自定义"对话框中,单击"工具栏"选项卡,在其下的下拉列表框中选择"快捷菜单"选项. 此时,屏幕

Win7旗舰版系统快速将便签等应用程序添加到右键菜单的技巧

  1.首先按"Win+r"组合快捷键打开"运行"窗口,输入regedit,回车打开注册表编辑器; 2.在打开的注册表编辑器中,依次展开定位到HKEY_CLASSES_ROOTDirectoryBackgroundshell,在shell下鼠标右击选择新建"项",例如记事本"NotePad"."QQ".截图工具"SnippingTool"; 3.随后在以上的项目中继续新建子"项

如何在IE右键菜单中添加菜单项

菜单|右键 如果使用过Netants的朋友可能都知道,NetAnts在IE中添加了右键菜单功能,只要在页面的一个链接或者图片上点击右键后在菜单中选择 Down By Netants 就可以调用Netants下载该链接指向的文件.在本文中作者将介绍如何通过VB来实现这样的功能. 要实现在IE右键菜单中添加菜单项的功能,要依次实现以下步骤: 1.在注册表HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt项下建立一个新项,项的名

win8右键菜单怎么自定义添加常用软件

  1.首先我们同事按下键盘上的win+R打开[运行],然后输入[regedit],然后确定打开注册表; 2.然后我们在注册表中依次找到HKEY_CLASSES_ROOTDirectorybackgroundshell; 3.点击[shell],并点击鼠标右键,选择[新建]-[项]; 4.然后将新建的项目重命名为自己喜欢的名称,当前小编以UC浏览器为例; 5.接着我们再给新建的UC浏览器添加一个子项,选中UC浏览器,点击鼠标右键,选择[新建][项],并给它命名为[command]; 6.接着我们