CSDN博客

img rui0370

jsp 中右键菜单的操作

发表于2004/9/25 19:10:00  4246人阅读

分类: 寒窗苦读

这几天很是郁闷,就因为屏蔽不掉右键菜单,后来终于解决了,一句话:form里加:oncontextmenu="return false"就会只显示自己的菜单了:)

下面是右键菜单的代码:

<style type="text/css">

 

.skin {BORDER-RIGHT: buttonhighlight 3px outset; BORDER-TOP: buttonhighlight 0px outset; FONT-SIZE: 9pt; VISIBILITY: hidden; BORDER-LEFT: buttonhighlight 0px outset; WIDTH: 100px; CURSOR: default; BORDER-BOTTOM: buttonhighlight 3px outset; FONT-FAMILY: Arial, Helvetica, sans-serif; POSITION: absolute; BACKGROUND-COLOR: #000000; TEXT-ALIGN: center}

.menuitems {PADDING-RIGHT: 10px; PADDING-LEFT: 10px}

td { font-size: 9pt; font-family: "宋体" color: #000000}

</style>

<script language="JavaScript1.2">

<!-- Begin

var menuskin = "skin";

var display_url = 0; // Show URLs in status bar?

function showmenuie5() {

var rightedge = document.body.clientWidth-event.clientX;

var bottomedge = document.body.clientHeight-event.clientY;

if (rightedge < ie5menu.offsetWidth)

ie5menu.style.left = document.body.scrollLeft + event.clientX - ie5menu.offsetWidth;

else

ie5menu.style.left = document.body.scrollLeft + event.clientX;

if (bottomedge < ie5menu.offsetHeight)

ie5menu.style.top = document.body.scrollTop + event.clientY - ie5menu.offsetHeight;

else

ie5menu.style.top = document.body.scrollTop + event.clientY;

ie5menu.style.visibility = "visible";

return false;

}

function hidemenuie5() {

ie5menu.style.visibility = "hidden";

}

function highlightie5() {

if (event.srcElement.className == "menuitems") {

event.srcElement.style.backgroundColor = "highlight";

event.srcElement.style.color = "white";

if (display_url)

window.status = event.srcElement.url;

   }

}

function lowlightie5() {

if (event.srcElement.className == "menuitems") {

event.srcElement.style.backgroundColor = "";

event.srcElement.style.color = "black";

window.status = "";

   }

}

function jumptoie5() {

if (event.srcElement.className == "menuitems") {

if (event.srcElement.getAttribute("target") != null)

window.open(event.srcElement.url, event.srcElement.getAttribute("target"));

else

window.location = event.srcElement.url;

   }

}

//  End -->

</script>

<div class="skin" id="ie5menu"

onmouseover="highlightie5()" style="LEFT: 80px; TOP: 28px" onclick="jumptoie5();"

onmouseout="lowlightie5()"><div>

 

<table height="100%" border="1" bordercolorlight=menu bordercolordark=buttonshadow bodercolor="menu" cellSpacing="1" cellPadding="1" width="100%" align="center"

bgColor="F8F8FF">

<TBODY>

<tr>

<td onmouseover="this.style.backgroundColor='captiontext';" onmouseout="this.style.backgroundColor='menu';"

bgColor="menu" height="20"><p align="left">&nbsp;&nbsp;<a href="javascript:AddSCWJ();">上传文件</a></td>

</tr>

<tr>

<td onmouseover="this.style.backgroundColor='captiontext';" onmouseout="this.style.backgroundColor='menu';"

bgColor="menu" height="20"><p align="left">&nbsp;&nbsp;<a href="javascript:AddGRSC();">新建收藏夹</a></td>

</tr>

<tr>

<td onmouseover="this.style.backgroundColor='captiontext';" onmouseout="this.style.backgroundColor='menu';"

bgColor="menu" height="20"><p align="left">&nbsp;&nbsp;<a href="javascript:RenameSC();">&nbsp;&nbsp;</a></td>

</tr>

<tr>

<td onmouseover="this.style.backgroundColor='captiontext';" onmouseout="this.style.backgroundColor='menu';"

bgColor="menu" height="20"><p align="left">&nbsp;&nbsp;<a href="javascript:RemoveSC();">&nbsp;&nbsp;&nbsp;&nbsp;</a></td>

</tr>

</TBODY>

</table>

</div></div>


  <script language="JavaScript1.2">

  if (document.all && window.print) {

  ie5menu.className = menuskin;

//document.oncontextmenu = showmenuie5;
        
document.body.onclick = hidemenuie5;

}

在希望显示的地方写:oncontextmenu = "javascript:showmenuie5();"就ok了:)

阅读全文
0 0

相关文章推荐

  • [jsp]JSP+DIV右键菜单
    claire68 2016-02-23 16:18 1271
  • JSP----jQuery插件ContextMenu生成右键菜单
    amandalm 2016-07-28 16:55 1711
  • JSP----jQuery插件ContextMenu生成右键菜单
    q383965374 2013-10-14 15:16 2887
  • java table右键点击事件
    qq_36238595 2017-05-30 14:49 482
  • sql 语句基本使用 笔记
    qq_28316183 2017-09-07 10:27 46
img
取 消
img