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

Javascript
兼容firefox的文本框只能输入两位小数的数字的代码
javascript 年月日联动实现核心代码
JavaScript 图片预览效果 推荐
JavaScript是否可实现多线程 深入理解JavaScript定时机制
jquery 表单取值常用代码
javaScript 删除确认实现方法小结
javascript强制弹出新窗口实现代码
Js倒计时代码,当鼠标离开页面与回到页面会自动停止与开始
Div+Js实现的带阴影菜单 微软以前网站曾用过
纯CSS实现的当鼠标移上图片添加阴影效果代码
JavaScript 未知高度元素垂直居中实现代码
javascript 仿开心网好友印象功能(点击文字弹出印象框)
JS+CSS实现的一种交互体验 表单页面
js 效率组装字符串 StringBuffer
window.js 主要包含了页面的一些操作
关于Aptana Studio生成自动备份文件的解决办法
javascript下arguments,caller,callee,call,apply示例及理解
HTA版JSMin(省略修饰语若干)基于javascript语言编写
CSS+Jquery实现页面圆角框方法大全
js 页面刷新location.reload和location.replace的区别小结

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


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