Add IE right button menu

Source: Internet
Author: User
Tags return tagname visibility window
Menu

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Customizing the right mouse button pop-up menu </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" >
pop-up menu
function Popupmouserightbuttonupmenu ()
{
Show Menu
if (mousemenu.style.visibility== ' visible ') mousemenu.style.visibility= ' hidden ';
If it is a link, text area, or input box, the IE menu is displayed
if (event.srcelement.tagname== ' A ' | | | event.srcelement.tagname== ' TEXTAREA ' | | | event.srcelement.tagname== ' INPUT ' | | document.selection.type!= ' None ')
return true;
Else
{
Prevent menus from being out of order
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 ';
}
Prohibit IE menu
return false;
}
Draw a menu, but not show
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&GT;&LT;\/TR&GT;&LT;TR&GT;&LT;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 () \ > back ', ' Window.history.forward () \ > forward '];
var sysmenu=[' \ "> lookup <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\ ') \ "> Select All",
' mousemenu.style.visibility=\ ' hidden\ ';d ocument.execcommand (\ ' saveas\ ', \ ' true\ ') \ "> Save As",
' Location.replace (\ ' view-source:\ ' +location.href) \ ' > View source files ',
' Mousemenu.style.visibility=\ ' hidden\ '; window.print () \ > print ',
' Window.location.reload () \ ' > refresh '];

var menustr= ';
for (i=0;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\ ') "> about ']
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;
Find string
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 (' Document search completed. ');
}
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 (' Document search completed. ');
}
}
return false;
}
</script>
<body>
Customizing the right mouse button pop-up menu
<a href=http://www.xrss.cn> Network Base </a>
<script language= "JavaScript" >
<!--
var menubarcolor = ' #6600FF ';
Drawmouserightbuttonupmenu ();
-->
</SCRIPT>
</body>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.