更改下你的那个东东发现它就在鼠标的下面,所以你是可能不能接触到网页的其它对象的,
下面的代码是关于单击鼠标右键,弹出的菜单会被覆盖
当运行下面的代码后,可以谈出自己定义的菜单,但是,不知道为什么左键不能选定其他对象,这是个很严重的问题,如果去掉onmousemove="MoveObj()";使其不在调用MoveObj()方法,,就可以选择其他对象,但是会出现一个新问题,就是说右键弹出菜单的时候就需要按两下鼠标才可以,且鼠标必须在同一位置!
这个问题如何解决,请教一下谢谢大家
<!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:100;height:100;"></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>
下面的代码是关于单击鼠标右键,弹出的菜单会被覆盖
当运行下面的代码后,可以谈出自己定义的菜单,但是,不知道为什么左键不能选定其他对象,这是个很严重的问题,如果去掉onmousemove="MoveObj()";使其不在调用MoveObj()方法,,就可以选择其他对象,但是会出现一个新问题,就是说右键弹出菜单的时候就需要按两下鼠标才可以,且鼠标必须在同一位置!
这个问题如何解决,请教一下谢谢大家
<!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:100;height:100;"></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>
<object id="objContent" classid="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A" style="position: absolute; top: 0; left: 0;width:100;height:100; display:none"></object>
在定了菜单内容后,只有在那东东身上按右键才显示菜单,
而你在不要了BODY的移动事件后,那东东就不会跟着你跑,这时你鼠标按下后,它跑来这了,再按右键时就因为在它身中按了右键,所以弹出菜单,
上面说过,困你用了移动事件,所以它会跟着跑,你左键先不了,