js编写弹出式菜单

做一个类似于window右键的弹出式菜单。

代码如下:

var obj;

function loadobj(o)
{
obj=o;
}

function expand()
{
var h=parseInt(obj.height);
var w=parseInt(obj.width);
var op=10;

if( h<=170 )
{
if( w<60 )
obj.style.width=w+6;

obj.style.height=h+17;

x=setTimeout('expand()', 25);
}
else
{
obj.style.width=60;
obj.style.height=174;
clearTimeout(x);
}
}

var drag=0;
var move=0;
function Dblclick()
{
if (event.button==0)
{
obj.style.visibility="visible";
obj.style.left=window.event.x;
obj.style.top =window.event.y;
obj.style.width=0;
obj.style.height=0;

obj.filters.item(0).apply();
obj.filters.item(0).transition = 25;
obj.filters(0).play(0.5);

expand();
}
}

function MouseMove()
{
if(move==1)
{
obj.style.cursor="move";
obj.style.left=window.event.x-l;
obj.style.top=window.event.y-t;
}
}

function MouseDown()
{
if(drag)
{
l = window.event.x - parseInt(obj.style.left);
t = window.event.y - parseInt(obj.style.top);
obj.style.zIndex+=1;
move=1;
}
else
{
document.body.style.cursor='default';
obj.style.visibility='hidden';
}
}

function MouseStop()
{
window.event.returnValue=false;
}

function MouseUp()
{
move=0;
obj.style.cursor="hand";
}

document.οndblclick=Dblclick;
document.οnmοusedοwn=MouseDown;
document.οnmοusemοve=MouseMove;
document.οndragstart=MouseStop;
document.οnmοuseup=MouseUp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值