自定义 IE 鼠标右键弹出式[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 playyuer 的 blog

<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';
 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';
    }
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.playyuer.com\\nmailto:playyuer@263.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' +

本文关键:JavaScript
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top