SoFunction
Updated on 2025-04-10

JavaScript custom right-click pop-up menu implementation method

This article describes the implementation method of JavaScript custom right-click pop-up menu. Share it for your reference. The specific implementation method is as follows:

<head runat="server">
<title>Untitled page</title>
<script type="text/javascript">
var oPopup = ();
function PopMenu(id)
{
 var oPopBody = ;
  = "buttonface";
  = "solid black 1px";
 var TableBegin="<table style=\"border: 0; width: 100%; font-size: 12px;\" cellpadding=\"0\" cellspacing=\"0\">";
 var Tr1="&lt;tr&gt;&lt;td valign=\"middle\" style=\"height: 20px;\" onmousemove=\"='highlight';='highlighttext'\" onmouseout=\"='';=''\" onclick=\"('/news/?');\">View the news</td></tr>";
 var TrBr1="&lt;tr&gt;&lt;td style=\"background-color: ThreeDShadow; height: 1px;\"&gt;&lt;/td&gt;&lt;/tr&gt;";
 var Tr2="&lt;tr&gt;&lt;td valign=\"middle\" style=\"height: 20px;cursor:hand;\" onmousemove=\"='highlight';='highlighttext'\" onmouseout=\"='';=''\" onclick=\"['main'].location='?;'\">View the news</td></tr>";
 var TableEnd="&lt;/table&gt;";
  =TableBegin+Tr1+TrBr1+Tr2+TableEnd;
 (, , 90, 41, );
 return false;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
 &lt;form  runat="server"&gt;
 &lt;div&gt;
  &lt;a href='javascript:void(0);' oncontextmenu='PopMenu(1);return false;'&gt;
  &lt;img alt="" src='' style="border:0;width:150px;height:110px; cursor:hand"/&gt;
  &lt;br/&gt;
  &lt;/a&gt;
  &lt;iframe name="main" frameborder="0" width="100%" scrolling="auto" height="100%"&gt;
  &lt;/iframe&gt;
 &lt;/div&gt;
 &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

I hope this article will be helpful to everyone's JavaScript programming.