There are many examples of disabling the right-click menu on a webpage. In fact, we can also replace the custom content with the right-click menu. In some cases, this is a good operation method. The principle is very simple. Let's take a look at the core code:
VaROpopup = Window. createpopup (); // create a pop-up menu instance
VaROpopbody = opopup.doc ument. Body; // set the menu content
Opopbody. innerhtml = "menu content"; // It can be merged into opopup.doc ument. Body. innerhtml = "menu content ";
Opopup. Show (event. X, event. Y, 90, 41, document. Body); // you can specify the width and height of the menu as needed.
It should be easy to understand. The following is an example of the background management page for image news. Right-click the image modification content, and right-click the image pop-up menu.
<HTML>
<Head>
<Title> Custom pop-up menu </title>
<Meta http-equiv = Content-Type content = "text/html; charset = gb2312">
<Link href = "../CSS/css.css" type = text/CSS rel = stylesheet>
<Link href = "../CSS/css2.css" type = text/CSS rel = stylesheet>
<Style type = "text/CSS">
<! --
Body TD
{
Font-size: 12px;
}
. Prompt
{
Height: 22; font-size: 12px;
Background-color: lightyellow;
Border: solid red 1px;
Position: absolute;
Left: 0; top: 0;
Padding: 4px;
Display: none;
Filter: alpha (opacity = 80 );
}
-->
</Style>
<Script language = "JavaScript">
VaROpopup = Window. createpopup ();
FunctionPopmenu (ID)
{
VaROpopbody = opopup.doc ument. Body;
Opopbody. style. backgroundcolor = "buttonface ";
Opopbody. style. Border = "solid black 1px ";
Opopbody. innerhtml = ""
+ "<Table cellpadding = 0 cellspacing = 0 border = 0 width = 100% style = 'font-size: 12px; '>"
+ "<Tr> <TD valign = Middle Height = 20 onmouseover = \" This. bgcolor = 'highlight'; this. style. Color = 'highlighttext ';\""
+ "Onmouseout = \" this. bgcolor = ''; this. style. color = ''\" onclick = \ "parent. window. open ('/news/view. asp? Id = "+ ID +" '); \ "> & nbsp; view this news </TD> </tr>"
+ "<Tr> <TD bgcolor = 'threedshadow 'Height = 1> </TD> </tr>"
+ "<Tr> <TD valign = Middle Height = 20 onmouseover = \" This. bgcolor = 'highlight'; this. style. Color = 'highlighttext ';\""
+ "Onmouseout = \" This. bgcolor = ''; this. style. Color ='' \ "onclick = \" parent.doc ument. Frames ['main']. Location ="
+ "'Newsimgdel. asp? Id = "+ ID +" '\ "> & nbsp; Delete </TD> </tr> <Table> ";
// + "<Tr> <TD bgcolor = 'threedhighlight' Height = 1> </TD> </tr>"
Hideprompt ();
Opopup. Show (event. X, event. Y, 90, 41, document. Body );
Return False;
}
FunctionShowprompt ()
{
PT. style. pixelleft = event. X;
PT. style. pixeltop = event. Y;
PT. style. Display = "Block ";
}
FunctionHideprompt ()
{
PT. style. Display = "NONE ";
}
</SCRIPT>
</Head>
<Body leftmargin = 0 topmargin = 0 marginheight = "0" marginwidth = "0" style = "text-align: center;">
<Div class = "prompt" id = "PT"> right-click Modify data, and right-click the operation menu & nbsp; </div>
<Table Height = "100%" width = "100%" border = "0" cellpadding = "0" cellspacing = "1" bgcolor = "333333"> <tr>
<TD width = "200" align = "Left" valign = "TOP" bgcolor = "# f2f2f2">
<Table border = "0" cellpadding = "0" cellspacing = "0" width = "100%" Height = "100%">
<Tr> <TD align = "center">
Image news
</TD> </tr> <TD>
</TD> </tr>
<Tr Height = "100%"> <TD Height = "100%" align = "center" valign = "TOP">
<Div style = "width: 200; Height: 100%; overflow: auto;"> <br>
<A href = 'javascript: void (0); 'onclick = "" onmouseover = 'showprompt (); 'onmouseout = 'hideprompt ();'
Oncontextmenu = 'popmenu (1); Return false; '> <br>
News image 1 <br> </a> <br>
<A href = 'javascript: void (0); 'onclick = "" onmouseover = 'showprompt (); 'onmouseout = 'hideprompt ();'
Oncontextmenu = 'popmenu (1); Return false; '> <br>
News Image 2 <br> </a> <br>
<A href = 'javascript: void (0); 'onclick = "" onmouseover = 'showprompt (); 'onmouseout = 'hideprompt ();'
Oncontextmenu = 'popmenu (1); Return false; '> <br>
News 3 <br> </a> <br>
<A href = 'javascript: void (0); 'onclick = "" onmouseover = 'showprompt (); 'onmouseout = 'hideprompt ();'
Oncontextmenu = 'popmenu (1); Return false; '> <br>
News Image 4 <br> </a> <br>
<A href = 'javascript: void (0); 'onclick = "" onmouseover = 'showprompt (); 'onmouseout = 'hideprompt ();'
Oncontextmenu = 'popmenu (1); Return false; '> <br>
News image 5 <br> </a> <br>
<A href = 'javascript: void (0); 'onclick = "" onmouseover = 'showprompt (); 'onmouseout = 'hideprompt ();'
Oncontextmenu = 'popmenu (1); Return false; '> <br>
News image 6 <br> </a> <br>
<Br> </div> </TD> </tr> </table> </TD> <TD bgcolor = "# ffffff">
<IFRAME name = "Main" frameborder = 0 width = 100% scrolling = auto Height = 100% src = "newsimg. asp"> </iframe>
</TD> </tr> </table>
</Body>
</Html>