絕對精彩:在網頁裡做類似window右鍵的彈出式選單 (轉)

worldblog發表於2007-12-05
絕對精彩:在網頁裡做類似window右鍵的彈出式選單 (轉)[@more@]

做一個類似於window右鍵的彈出式選單。

直接js和觀看效果: s/jscripts.htm">~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 lclick()
{
  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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章