虚心请教:如何在图片上点鼠标右键的时候我想显示我自己的右键快捷菜单,而不是显示IE默认的快捷菜单呢? 找一个右键菜单先,用鼠标判断所在的对象是不是image1,是的话就弹出菜单. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE> New Document </TITLE><SCRIPT LANGUAGE="JavaScript">//show(x-location, y-location, width, height[, reference-element]);var oPopup = window.createPopup();//初始化窗体function initPopupWin(){ oPopupBody = oPopup.document.body; oPopupBody.innerHTML = popupMenu.innerHTML; oPopupBody.style.textAlign = "center"; oPopupBody.style.backgroundColor = "#ffff66"; oPopupBody.style.border = "1 solid green"; oPopupBody.style.fontSize = "9pt"; oPopupBody.style.fontFamily = "Courier New";}//显示窗体function showPopupWin(referenceObj){ initPopupWin(); var xPos = event.offsetX+10; var yPos = event.offsetY+0; var width = 50; var height = 105; oPopup.show(xPos,yPos,width,height,referenceObj);}function test(obj,id,rowId){ currentRow.value = rowId; showPopupWin(obj);}function deleteRow_f(rowId,delTable){ delTable.deleteRow(rowId);}function saveRow_f(rowId,saveTable){ var objTR = saveTable.firstChild.childNodes[rowId]; var children = objTR.childNodes.length; var result; for(i=0;i<children-1;i++){ result = objTR.childNodes[i].firstChild.value; if(typeof(result)=="undefined"){ return; } result = " "+result+" "; if(result==""){ result = " "; } objTR.childNodes[i].innerText=result; }}function modify_f(rowId,modiTable){ var objTR = modiTable.firstChild.childNodes[rowId]; var children = objTR.childNodes.length; var text; for(i=0;i<children-1;i++){ text=objTR.childNodes[i].innerText; objTR.childNodes[i].innerHTML = "<input type='text' style='height:17px;width:100%' value="+text+">"; } objTR.childNodes[i].innerHTML = "<img src='list.gif' border='0' value='1' onContextmenu='test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;' alt='单击右键'>";}function insertRow_f(rowId,insertTable){ var newRow = insertTable.insertRow(rowId); var col = newRow.insertCell(0); col.innerHTML = "<input type='text' style='height:17px;width:100%'>"; col = newRow.insertCell(1); col.innerHTML = "<input type='text' style='height:17px;width:100%'>"; col = newRow.insertCell(2); col.innerHTML = "<input type='text' style='height:17px;width:100%'>"; col = newRow.insertCell(3); col.innerHTML = "<input type='text' style='height:17px;width:100%'>"; col = newRow.insertCell(4); col.innerHTML = "<img src='list.gif' border='0' value='1' onContextmenu='test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;' alt='单击右键'>";}</SCRIPT></HEAD><BODY><TABLE border="1" align="center" borderColorLight="pink" width="50%" id=listTable name=listTable cols=5 style="font-size: 9pt;text-align:center"><TR borderColorLight="yellowgreen" bgcolor="gainsboro" style="font-size: 11pt;"> <TD>商品代码</TD> <TD>商品名称</TD> <TD>计价单位</TD> <TD>库存数量</TD> <TD>操作</TD></TR><TR> <TD>GOODS000000000000001</TD> <TD>保10洁</TD> <TD>辆</TD> <TD>1</TD> <TD><img src="list.gif" border="0" value="1" onContextmenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD></TR><TR> <TD>GOODS000000000000002</TD> <TD>小猪猪</TD> <TD>只</TD> <TD>only you</TD> <TD><img src="list.gif" border="0" value="2" onContextMenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD></TR><TR> <TD>GOODS000000000000003</TD> <TD>千年人参</TD> <TD>棵</TD> <TD>10</TD> <TD><img src="list.gif" border="0" value="1" onContextmenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD></TR><TR> <TD>GOODS000000000000004</TD> <TD>脑白金</TD> <TD>盒</TD> <TD>50</TD> <TD><img src="list.gif" border="0" value="1" onContextmenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD></TR><TR> <TD>GOODS000000000000005</TD> <TD>白吃</TD> <TD>个</TD> <TD>31</TD> <TD><img src="list.gif" border="0" value="1" onContextmenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD></TR><TR> <TD>GOODS000000000000006</TD> <TD>第十一本书</TD> <TD>本</TD> <TD>01</TD> <TD><img src="list.gif" border="0" value="1" onContextmenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD></TR></TABLE><DIV id=popupMenu style="display:none"><input type="hidden" id="currentRow"><TABLE border=1 bordercolor="white" bgcolor="wheat" borderColorLight="yellowgreen" style="font-size: 9pt;" width="100%" height="100%"> <TR align="center"> <TD> <DIV STYLE="cursor:hand" onmouseover="this.style.background='seashell'" onmouseout="this.style.background='wheat'" onclick="parent.insertRow_f(parent.listTable.rows.length,parent.listTable);parent.oPopup.hide();">添加</DIV> </TD> </TR> <TR align="center"> <TD> <DIV STYLE="cursor:hand" onmouseover="this.style.background='seashell'" onmouseout="this.style.background='wheat'" onclick="parent.saveRow_f(currentRow.value,parent.listTable);parent.oPopup.hide();">保存</DIV> </TD> </TR> <TR align="center"> <TD> <DIV STYLE="cursor:hand" onmouseover="this.style.background='seashell'" onmouseout="this.style.background='wheat'" onclick="parent.deleteRow_f(currentRow.value,parent.listTable);parent.oPopup.hide();">删除</DIV> </TD> </TR> <TR align="center"> <TD> <DIV STYLE="cursor:hand" onmouseover="this.style.background='seashell'" onmouseout="this.style.background='wheat'" onclick="parent.modify_f(currentRow.value,parent.listTable);parent.oPopup.hide();">修改</DIV> </TD> </TR> <TR align="center"> <TD> <DIV STYLE="cursor:hand" onmouseover="this.style.background='seashell'" onmouseout="this.style.background='wheat'" onclick="parent.insertRow_f(currentRow.value,parent.listTable);parent.oPopup.hide();">插入</DIV> </TD> </TR></TABLE></DIV></BODY></HTML> javaEidolon您的方法不行的。我尝试过了。 自己先做一个,然后return false屏蔽掉 <img border=0 src=http://expert.csdn.net/images/csdn.gif oncontextmenu="cc(this); return false"> <div id=pop style="position:absolute;width:100;height:50;z-index:99;display:none"><table border=0 bgcolor=#FF0000><tr><td align=center>图层菜单</td></tr></table></div><script language="JavaScript"><!--function cc(tt){ var daps = document.all.pop.style; var ttop = tt.offsetTop; //TT控件的定位点高 var thei = tt.clientHeight; //TT控件本身的高 var tleft = tt.offsetLeft; //TT控件的定位点宽 var ttyp = tt.type; //TT控件的类型 while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;} daps.top = (ttyp=="image")? ttop+thei : ttop+thei+6; //层的 Y 坐标 daps.left = tleft + 1; //层的 X 坐标 daps.display = ""; //层显示}function document.onclick(){ document.all.pop.style.display=event.srcElement.tagName=="img"?'':'none'}//--></script> ><img src="list.gif" border="0" value="1" onContextmenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键">注意这里有一个return false;的。 请问JS如何获取其他页面传递来的值? 新手求问 JS下拉框,字符长度控制 【【如何取得checkbox的lable标签值???】】 "文件未依Teleport Pro取回...\n\n"的问题谢谢高手帮忙 XML样式问题 求一正则表达式 *.txt 在线等 紧急!有关下拉列表和复选框的问题 window.location.href='index.jsp'中的"location"是什么意思?(100分,回答全者给分多) 帮我!!很急 如何让text 里的值为右对齐???? 很简单的问题,谁先解答正确给谁50分
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<SCRIPT LANGUAGE="JavaScript">
//show(x-location, y-location, width, height[, reference-element]);
var oPopup = window.createPopup();//初始化窗体
function initPopupWin(){
oPopupBody = oPopup.document.body;
oPopupBody.innerHTML = popupMenu.innerHTML;
oPopupBody.style.textAlign = "center";
oPopupBody.style.backgroundColor = "#ffff66";
oPopupBody.style.border = "1 solid green";
oPopupBody.style.fontSize = "9pt";
oPopupBody.style.fontFamily = "Courier New";
}//显示窗体
function showPopupWin(referenceObj){
initPopupWin();
var xPos = event.offsetX+10;
var yPos = event.offsetY+0;
var width = 50;
var height = 105;
oPopup.show(xPos,yPos,width,height,referenceObj);
}function test(obj,id,rowId){
currentRow.value = rowId;
showPopupWin(obj);
}function deleteRow_f(rowId,delTable){
delTable.deleteRow(rowId);
}function saveRow_f(rowId,saveTable){
var objTR = saveTable.firstChild.childNodes[rowId];
var children = objTR.childNodes.length;
var result;
for(i=0;i<children-1;i++){
result = objTR.childNodes[i].firstChild.value;
if(typeof(result)=="undefined"){
return;
}
result = " "+result+" ";
if(result==""){
result = " ";
}
objTR.childNodes[i].innerText=result;
}
}function modify_f(rowId,modiTable){
var objTR = modiTable.firstChild.childNodes[rowId];
var children = objTR.childNodes.length;
var text;
for(i=0;i<children-1;i++){
text=objTR.childNodes[i].innerText;
objTR.childNodes[i].innerHTML = "<input type='text' style='height:17px;width:100%' value="+text+">";
}
objTR.childNodes[i].innerHTML = "<img src='list.gif' border='0' value='1' onContextmenu='test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;' alt='单击右键'>";
}function insertRow_f(rowId,insertTable){
var newRow = insertTable.insertRow(rowId);
var col = newRow.insertCell(0); col.innerHTML = "<input type='text' style='height:17px;width:100%'>";
col = newRow.insertCell(1);
col.innerHTML = "<input type='text' style='height:17px;width:100%'>";
col = newRow.insertCell(2);
col.innerHTML = "<input type='text' style='height:17px;width:100%'>";
col = newRow.insertCell(3);
col.innerHTML = "<input type='text' style='height:17px;width:100%'>";
col = newRow.insertCell(4);
col.innerHTML = "<img src='list.gif' border='0' value='1' onContextmenu='test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;' alt='单击右键'>";
}</SCRIPT>
</HEAD><BODY>
<TABLE border="1" align="center" borderColorLight="pink" width="50%" id=listTable name=listTable cols=5 style="font-size: 9pt;text-align:center">
<TR borderColorLight="yellowgreen" bgcolor="gainsboro" style="font-size: 11pt;">
<TD>商品代码</TD>
<TD>商品名称</TD>
<TD>计价单位</TD>
<TD>库存数量</TD>
<TD>操作</TD>
</TR>
<TR>
<TD>GOODS000000000000001</TD>
<TD>保10洁</TD>
<TD>辆</TD>
<TD>1</TD>
<TD><img src="list.gif" border="0" value="1" onContextmenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD>
</TR>
<TR>
<TD>GOODS000000000000002</TD>
<TD>小猪猪</TD>
<TD>只</TD>
<TD>only you</TD>
<TD><img src="list.gif" border="0" value="2" onContextMenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD>
</TR>
<TR>
<TD>GOODS000000000000003</TD>
<TD>千年人参</TD>
<TD>棵</TD>
<TD>10</TD>
<TD><img src="list.gif" border="0" value="1" onContextmenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD>
</TR>
<TR>
<TD>GOODS000000000000004</TD>
<TD>脑白金</TD>
<TD>盒</TD>
<TD>50</TD>
<TD><img src="list.gif" border="0" value="1" onContextmenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD>
</TR>
<TR>
<TD>GOODS000000000000005</TD>
<TD>白吃</TD>
<TD>个</TD>
<TD>31</TD>
<TD><img src="list.gif" border="0" value="1" onContextmenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD>
</TR>
<TR>
<TD>GOODS000000000000006</TD>
<TD>第十一本书</TD>
<TD>本</TD>
<TD>01</TD>
<TD><img src="list.gif" border="0" value="1" onContextmenu="test(this,this.value,this.parentNode.parentNode.sectionRowIndex);return false;" alt="单击右键"></TD>
</TR>
</TABLE><DIV id=popupMenu style="display:none">
<input type="hidden" id="currentRow">
<TABLE border=1 bordercolor="white" bgcolor="wheat" borderColorLight="yellowgreen" style="font-size: 9pt;" width="100%" height="100%">
<TR align="center">
<TD>
<DIV STYLE="cursor:hand" onmouseover="this.style.background='seashell'" onmouseout="this.style.background='wheat'" onclick="parent.insertRow_f(parent.listTable.rows.length,parent.listTable);parent.oPopup.hide();">添加</DIV>
</TD>
</TR>
<TR align="center">
<TD>
<DIV STYLE="cursor:hand" onmouseover="this.style.background='seashell'" onmouseout="this.style.background='wheat'" onclick="parent.saveRow_f(currentRow.value,parent.listTable);parent.oPopup.hide();">保存</DIV>
</TD>
</TR>
<TR align="center">
<TD>
<DIV STYLE="cursor:hand" onmouseover="this.style.background='seashell'" onmouseout="this.style.background='wheat'" onclick="parent.deleteRow_f(currentRow.value,parent.listTable);parent.oPopup.hide();">删除</DIV>
</TD>
</TR>
<TR align="center">
<TD>
<DIV STYLE="cursor:hand" onmouseover="this.style.background='seashell'" onmouseout="this.style.background='wheat'" onclick="parent.modify_f(currentRow.value,parent.listTable);parent.oPopup.hide();">修改</DIV>
</TD>
</TR>
<TR align="center">
<TD>
<DIV STYLE="cursor:hand" onmouseover="this.style.background='seashell'" onmouseout="this.style.background='wheat'" onclick="parent.insertRow_f(currentRow.value,parent.listTable);parent.oPopup.hide();">插入</DIV>
</TD>
</TR>
</TABLE>
</DIV>
</BODY>
</HTML>
oncontextmenu="cc(this); return false"> <div id=pop style="position:absolute;width:100;height:50;z-index:99;display:none">
<table border=0 bgcolor=#FF0000><tr><td align=center>图层菜单</td></tr></table></div><script language="JavaScript"><!--
function cc(tt)
{
var daps = document.all.pop.style;
var ttop = tt.offsetTop; //TT控件的定位点高
var thei = tt.clientHeight; //TT控件本身的高
var tleft = tt.offsetLeft; //TT控件的定位点宽
var ttyp = tt.type; //TT控件的类型
while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
daps.top = (ttyp=="image")? ttop+thei : ttop+thei+6; //层的 Y 坐标
daps.left = tleft + 1; //层的 X 坐标
daps.display = ""; //层显示
}
function document.onclick()
{
document.all.pop.style.display=event.srcElement.tagName=="img"?'':'none'
}
//--></script>
注意这里有一个return false;的。