做一个类似于window右键的弹出式菜单。
代码如下:
var obj;
function loadobj(o)w4eLinux联盟
{w4eLinux联盟
obj=o;w4eLinux联盟
}
function expand()w4eLinux联盟
{w4eLinux联盟
var h=parseInt(obj.height);w4eLinux联盟
var w=parseInt(obj.width);w4eLinux联盟
var op=10;
if( h<=170 )w4eLinux联盟
{w4eLinux联盟
if( w<60 )w4eLinux联盟
obj.style.width=w+6;
obj.style.height=h+17;
x=setTimeout('expand()', 25);w4eLinux联盟
}w4eLinux联盟
elsew4eLinux联盟
{w4eLinux联盟
obj.style.width=60;w4eLinux联盟
obj.style.height=174;w4eLinux联盟
clearTimeout(x);w4eLinux联盟
}w4eLinux联盟
}
var drag=0;w4eLinux联盟
var move=0;w4eLinux联盟
function Dblclick()w4eLinux联盟
{w4eLinux联盟
if (event.button==0)w4eLinux联盟
{w4eLinux联盟
obj.style.visibility="visible";w4eLinux联盟
obj.style.left=window.event.x;w4eLinux联盟
obj.style.top =window.event.y;w4eLinux联盟
obj.style.width=0;w4eLinux联盟
obj.style.height=0;
obj.filters.item(0).apply();w4eLinux联盟
obj.filters.item(0).transition = 25;w4eLinux联盟
obj.filters(0).play(0.5);
expand();w4eLinux联盟
}w4eLinux联盟
}
function MouseMove()w4eLinux联盟
{w4eLinux联盟
if(move==1)w4eLinux联盟
{w4eLinux联盟
obj.style.cursor="move";w4eLinux联盟
obj.style.left=window.event.x-l; w4eLinux联盟
obj.style.top=window.event.y-t;w4eLinux联盟
}w4eLinux联盟
}
function MouseDown()w4eLinux联盟
{w4eLinux联盟
if(drag) w4eLinux联盟
{w4eLinux联盟
l = window.event.x - parseInt(obj.style.left);w4eLinux联盟
t = window.event.y - parseInt(obj.style.top);w4eLinux联盟
obj.style.zIndex+=1;w4eLinux联盟
move=1;w4eLinux联盟
}w4eLinux联盟
elsew4eLinux联盟
{w4eLinux联盟
document.body.style.cursor='default'; w4eLinux联盟
obj.style.visibility='hidden';w4eLinux联盟
}w4eLinux联盟
}
function MouseStop()w4eLinux联盟
{w4eLinux联盟
window.event.returnValue=false;w4eLinux联盟
}
function MouseUp()w4eLinux联盟
{w4eLinux联盟
move=0;w4eLinux联盟
obj.style.cursor="hand";w4eLinux联盟
}
document.ondblclick=Dblclick;w4eLinux联盟
document.onmousedown=MouseDown;w4eLinux联盟
document.onmousemove=MouseMove;w4eLinux联盟
document.ondragstart=MouseStop;w4eLinux联盟
document.onmouseup=MouseUp;
Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论