下面的代码是关于单击鼠标右键,弹出的菜单会被覆盖
请问这其中的几句话应该怎么理解(1)<body onmousemove="MoveObj()"  onmousedown="MoveObj()" onmouseup="MoveObj()" >
答:是否是当鼠标移动,按下,谈出都会调用script的MoveObj()方法,(2)<object id="objContent" classid="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A" style="position: absolute; top: 0; left: 0;width:1;height:1;"></object>
问:这句话代表什么意思,希望具体些,谢谢(3)objContent.SetContextMenu(menuStrings, menuStates);
问:这句话代表什么意思,是设置鼠标吧(4)当运行下面的代码后,可以谈出自己定义的菜单,但是,不知道为什么左键不能选定其他对象,这是个很严重的问题,希望帮助解决!谢谢!<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<title>系统菜单-51windows.Net</title>
<head>
<meta name="keywords" content="51windows.Net">
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
</head>
<body onmousemove="MoveObj()"  onmousedown="MoveObj()" onmouseup="MoveObj()" >
<p>请点右键</p><object id="objContent" classid="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A" style="position: absolute; top: 0; left: 0;width:1;height:1;"></object><SCRIPT LANGUAGE="JavaScript">function fu(id){
document.write("123");
}var ContextMenu = new Array() ;
function ContextMenuItem(text, command, state){
this.Text = text ;
this.Command = command || "void(0)" ;
this.state = state;
}ContextMenu[0] = new ContextMenuItem("前进(&B)","go(1)",0);
ContextMenu[1] = new ContextMenuItem("后退(&O)","abc()",0);
ContextMenu[2] = new ContextMenuItem("未选中(&S)","s()",0);
ContextMenu[3] = new ContextMenuItem("","",0);
ContextMenu[4] = new ContextMenuItem("新窗口(&W)","window.open('http://www.baidu.com')",0);for (i = 5 ; i < 10; i++ ){
ContextMenu[i] = new ContextMenuItem("菜单 (&"+i+")","ContextMenu["+i+"].state=(ContextMenu["+i+"].state==0)?1:0",0);
}function s(){
if (ContextMenu[2].Text == "选中(&S)"){
ContextMenu[2].Text = "未选中(&S)";
ContextMenu[2].state = 0;
}
else{
ContextMenu[2].Text = "选中(&S)";
ContextMenu[2].state = 1;
}
}function go(n){
ContextMenu[0].state = (n==1)?2:0;
ContextMenu[1].state = (n==1)?0:2;

}function abc(){
     for(i = 1;i < 100 ; i++ ){
            document.write(i);
     }
}function showContextMenu(iMenu){
var i ;
var menuStrings = new Array();
var menuStates  = new Array();
for ( i = 0 ; i < ContextMenu.length ; i++ ){
menuStrings[i] = ContextMenu[i].Text ;
menuStates[i] = ContextMenu[i].state ;
}
objContent.SetContextMenu(menuStrings, menuStates);
}
function MoveObj(){
objContent.style.top = window.event.y-2
objContent.style.left = window.event.x-2
}</SCRIPT><script language="javascript" event="ShowContextMenu" for="objContent">showContextMenu(ContextMenu) ;</script><script language="javascript" event="ContextMenuAction(itemIndex)" for="objContent">eval(ContextMenu[itemIndex].Command);</script></html>

解决方案 »

  1.   

    1)
    写的没错,是都会触发MoveObj函数但是只有onmousemove事件起作用,因为当鼠标按下和弹起来时都会先触发onmousemove事件2)注册控件
    )<object id="objContent" classid="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A" style="position: absolute; top: 0; left: 0;width:1;height:1;"></object>
    classid是注册表中的值,style后面的是样式:位置、高、左、长和宽
      

  2.   

    但是第四个问题,的确可以选择菜单里的内容,但是在原始状态鼠标左键不能选择页面上的对象了,例如文字,图片等,这个该怎么解决?有时间的话能帮我想一想么?我的QQ是56593930 
    mail: [email protected]
    谢谢各位的支持!
      

  3.   

    其实第四个问题是在
    <body onmousemove="MoveObj()"  onmousedown="MoveObj()" onmouseup="MoveObj()" >
    这里.
    如果去掉onmousemove="MoveObj()";使其不在调用MoveObj()方法,,就可以选择其他对象,
    但是会出现一个新问题,就是说右键弹出菜单的时候就需要按两下鼠标才可以
    这个问题如何解决,请教一下
      

  4.   

    window.event.button==2这个是判断鼠标的键值 2 就是右键也就是if(window.event.button==2){//显示菜单}这样就不会影响左键的操作了~