右键菜单制作问题求教,谢谢

tooogooo 2004-10-08 02:17:28
<IMG id="1" src="1.gif">
1.如何做一个该图片的右键菜单,只对该图片有效,其他地方无效。
2.右键菜单里有一个删除该控件的按纽,该按纽根据srcElement.id删除。而不是根据childNotes.length删除。
请问各位大哥大姐,谢谢。
...全文
140 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
tooogooo 2004-10-08
  • 打赏
  • 举报
回复
谢谢孟子大哥
我大概明白了,谢谢
孟子E章 2004-10-08
  • 打赏
  • 举报
回复
<style>
< !--
.skin0 {
position:absolute;
text-align:left;
width:200px;
border:2px solid black;
background-color:menu;
font-family:Verdana;
line-height:20px;
cursor:default;
visibility:hidden;
}
.skin1 {
cursor:default;
font:menutext;
position:absolute;
text-align:left;
font-family: Arial, Helvetica, sans-serif;
font-size: 10pt;
width:120px;
background-color:menu;
border:1 solid buttonface;
visibility:hidden;
border:2 outset buttonhighlight;
}
.menuitems {
padding-left:15px;
padding-right:10px;
}
-->
</style>

<SCRIPT LANGUAGE="JavaScript1.2">

var menuskin = "skin1"; // skin0, or skin1
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 id="ie5menu" class="skin0" onMouseover="highlightie5()"
onMouseout="lowlightie5()"   onClick="jumptoie5();">
<div class="menuitems" url="javascript:history.back();">返回</div>
<div class="menuitems" url="http://javacool.3322.net">回首页</div>
<hr>
<div class="menuitems" url="http://www.163.com">网易</div>
<div class="menuitems" url="http://www.sohu.com">搜狐</div>
<hr>
<div class="menuitems" url="http://www.sina.com.cn">新浪</div>
<div class="menuitems" url="http://www.yahoo.com.cn">雅虎</div>
</div>
<script language="JavaScript1.2">
if (document.all && window.print) {
ie5menu.className = menuskin;

document.body.onclick = hidemenuie5;
}

</script>
<img src="http://dotnet.aspx.cc/Images/logoSite.gif" oncontextmenu="showmenuie5();return false">
tooogooo 2004-10-08
  • 打赏
  • 举报
回复
谢谢孟子大哥
oncontextmenu我知道用,但是函数我还不懂写,就上面我说的该怎么写出一个菜单格式,指点我一下好么,谢谢
孟子E章 2004-10-08
  • 打赏
  • 举报
回复
<IMG id="1" src="1.gif" oncontextmenu="xx()">

xx()是显示右键菜单的js函数
tooogooo 2004-10-08
  • 打赏
  • 举报
回复
谢谢,但是function()里怎么才能做出菜单呢?
function ti()
{
<TABLE id="Table1" style="Z-INDEX: 102; LEFT: 336px; WIDTH: 104px; POSITION: absolute; TOP: 128px; HEIGHT: 75px"
cellSpacing="1" cellPadding="1" width="104" border="1">
<TR>
<TD style="WIDTH: 25px; HEIGHT: 23px"></TD>
<TD style="HEIGHT: 23px"><FONT face="宋体">1</FONT></TD>
</TR>
<TR>
<TD style="WIDTH: 25px; HEIGHT: 18px"></TD>
<TD style="HEIGHT: 18px"><FONT face="宋体">2</FONT></TD>
</TR>
<TR>
<TD style="WIDTH: 25px"></TD>
<TD><FONT face="宋体">3</FONT></TD>
</TR>
</TABLE>
}
肯定不是这样,贴这些出来是为了更清楚的表达意思。。。
yjgx007 2004-10-08
  • 打赏
  • 举报
回复
1.removeNode();
yjgx007 2004-10-08
  • 打赏
  • 举报
回复
<IMG id="1" src="1.gif">

<script>
1.onmouseup = function() {
... show menu
}
</script>

删除直接调用removeNode

87,902

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧