当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 绝对精彩:在网页里做类似window右键的弹出式菜单

Javascript
动态生成select选项全接触
不刷新页面动态更新select选项,实现两个select相互操作
网页输入框日期型有效性判定一网打尽
实用Javascript函数之一(自动将输入文本框中的内容转换成大写字符)
实用Javascript函数之二(自动将输入文本框中的内容转换成小写字符)
实用Javascript函数之三(限制文本输入框中只能输入数字\"0\"到\"9\")
实用Javascript函数之四(用于对sString字符串进行前空格截除)
实用Javascript函数之五(用于对sString字符串进行后空格截除)
实用Javascript函数之六(截除字符串前后空格)
如何使用交替的滚动标题
采用DOM模型时创建一个Select节点后,要删除option项的解决方法
javascript函数速查
利用JavaScript和正则表达式进行丰富的日期判断(给其它项目组的代码,有比较好的编程风格和注释)
关于字符串的几个有用函数
FileSystemObject 的例子(处理驱动器、文件夹、文件)
用JScript实现VB.Net,C#的[委托Delegate]:
得到固定字符位置的函数
IE NC通用的藏鼠标右键一法
Menu
foolpot2001菜单

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 131 ::
收藏到网摘: n/a

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

直接下载js文件和观看效果: 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;