ITPub博客

首页 > IT基础架构 > 网络安全 > 绝对精彩:在网页里做类似window右键的弹出式菜单 (转)

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

原创 网络安全 作者:a400 时间:2007-08-13 09:08:20 0 删除 编辑
绝对精彩:在网页里做类似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博客 ” ,链接:https://blog.itpub.net/10790690/viewspace-952984/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    826
  • 访问量
    305777