绝对精彩:在网页里做类似window右键的弹出式菜单 (转)

本文介绍了一种在网页中实现类似Windows右键弹出菜单的方法。通过JavaScript代码,可以创建一个随鼠标双击出现并逐渐展开的弹出式菜单。此外,还提供了完整的JavaScript代码示例及在线演示。
绝对精彩:在网页里做类似window右键的弹出式菜单 (转)[@more@]

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

直接下载js文件和观看效果: jscripts/jscripts.htm">http://202.114.98.14/~cityhunter/jscripts/jscripts.htm
代码如下: 

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.ondblclick=Dblclick;
document.onmousedown=MouseDown;
document.onmousemove=MouseMove;
document.ondragstart=MouseStop;
document.onmouseup=MouseUp;


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-988656/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-988656/

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值