SoFunction
Updated on 2025-02-28

Rewrite the implementation code of Cognos right-click menu using JS


<!--Menu Style-->
<STYLE type=text/css>
.cMenu {
BORDER-RIGHT: #000000 1px solid;
BORDER-TOP: #000000 1px solid;
FONT-WEIGHT: normal;
FONT-SIZE: 14px;
VISIBILITY: hidden;
BORDER-LEFT: #000000 1px solid;
WIDTH: 150px;
CURSOR: default;
COLOR: #000000;
LINE-HEIGHT: 20px;
BORDER-BOTTOM: #000000 1px solid;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
POSITION: absolute;
BACKGROUND-COLOR: #eeeeff
}
.menuitems {
PADDING-RIGHT: 5px;
PADDING-LEFT: 5px
}
</STYLE>
<DIV class=cMenu onmouseover=highLightMenu() onmouseout=lowLightMenu()>
<DIV class=menuitems clickcall="alert('View historical execution');">View historical execution</DIV>
<DIV class=menuitems clickcall="alert('View comment');">View comment</DIV>
<DIV class=menuitems clickcall="alert('Insert/Modify Annotation');">Insert/Modify Annotation</DIV>
<HR color=#aaaaaa size="0">
<DIV class=menuitems clickcall="alert('About');">About</DIV>
</DIV>
<SCRIPT type="text/javascript">
var contextMenu = ("contextMenu");
function getObjectName()
{
return ("").value;
}
function getRVContent()
{
var objName = getObjectName();
return eval("('RVContent" + objName + "');");
}
function overWriteRightClick()//Rewrite pop-up menu
{
var objName = getObjectName();
eval("oCV" + objName + ". = displayContextMenu;");
}
function disableRightClick()
{
var objName = getObjectName();
eval("oCV" + objName + ".bCanUseCognosViewerContextMenu = false;");
}
/* Menu related functions start*/
function displayContextMenu(evt) {
evt = (evt) ? evt : ((event) ? event : null);
hideContextMenu();
var rightedge = getRVContent().clientWidth - ;
var bottomedge = getRVContent().clientHeight - ;
if (rightedge < )
= getRVContent().scrollLeft + - - getRVContent().offsetLeft;
else
= getRVContent().scrollLeft + - getRVContent().offsetLeft;
if (bottomedge < )
= getRVContent().scrollTop + - - getRVContent().offsetTop;
else
= getRVContent().scrollTop + - getRVContent().offsetTop;
= "visible";
return false;
}
function hideContextMenu() {
var object = ;
= "hidden";
if ( == "menuitems") {
eval();
}
}
function highLightMenu() {
var object = ;
if ( == "menuitems") {
= "highlight";
= "white";
}
}
function lowLightMenu() {
var object = ;
if ( == "menuitems") {
= "";
= "black";
}
}
/* Menu related functions end*/
overWriteRightClick();
= hideContextMenu;
</SCRIPT>