用户登陆:
设为首页 | 加入收藏 | 免费邮箱
建站学院: 建站心得 | 搜索优化 | 建站点子 | 网站推广 | 网站推荐 | 企业新闻 | 人物新闻 | 网媒内幕 | 域名相关 | 热门专题 | 本站作品
设计学院: 网页设计 | 平面设计 | 网络编程 | 多媒体类 | 数据库类 | 服务器类 | 操作系统 | 联盟新闻 | 联盟介绍 | 联盟点评 | 网赚技巧
模板下载: 旅游度假 | 饮食食品 | 公司展示 | 学校教育 | 文化艺术 | 金融财经 | 儿童卡通 | 体育运动 | 服饰品牌 | 爱情交友 | 游戏娱乐
您现在的位置: 星星雨设计站 >> 设计学院 >> 网页设计 >> Javascript >> 教程正文
在网页里做类似window右键的弹出式菜单
作者:佚名    教程来源:不详    点击数:    更新时间:2007-11-18

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

代码如下: 

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;

发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口教程录入:冰河    责任编辑:冰河 
  网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
最新热门
最新推荐
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明