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

Javascript
jquery 弹出层实现代码
jQuery 扩展对input的一些操作方法
扩展jQuery 键盘事件的几个基本方法
Iframe 自适应高度并实时监控高度变化的js代码
CCPry JS类库 代码
jquery text()要注意啦
json 入门基础教程 推荐
json 实例详细说明教程
JavaScript中的JSON 中文版翻译
javascript GUID生成器实现代码
DOM 脚本编程中的兄弟节点
JavaScript Sort 表格排序
提高网站性能之 如何对待JavaScript
js 函数的执行环境和作用域链的深入解析
键盘 keycode的值 javascript时触发事件时很有用的要素
cnblogs csdn 代码运行框实现代码
简单实用的HTML到UBB转换脚本工具实现说明
Javascript结合css实现网页换肤功能
JQuery 网站换肤功能实现代码
JS OOP包机制,类创建的方法定义

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 154 ::
收藏到网摘: 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;