浪迹天涯
web报表设计器....
posts - 60,comments - 71,trackbacks - 0

 

< HTML >
< HEAD >

< TITLE >  Web表格生成器  </ TITLE >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=gb2312" >
< BODY  oncontextmenu =window.event.returnValue=false  bgcolor ="#ffffff" >
   
< style  type ="text/css" >
  <!--
  body           
{ font-size :  9pt ; }
  table          
{ font-size :  9pt ;  cursor :  default ;  margin :  0 ; }
  tr             
{ height :  20 ; }
  tr.over        
{ font-size :  9pt ;  color :  #ffffff ;  background-color :  #000080 ;  cursor :  default ; }
  tr.out         
{ font-size :  9pt ;  color :  #000000 ;  background-color :  #D4D0C8 ;  cursor :  default ; }
  div.rm_div     
{ position :  absolute ;  filter :  Alpha(Opacity='95') ;  display :  none ;  background-color :  #D4D0C8 ;  border :  2px outset #FFFFFF ; width :  0 ;  height :  0 ; padding : 1 }
  hr.sperator    
{ width : 95% ; border :  1px inset #FFFFFF ; }
  -->
  
</ style >
  
< script  language ="javascript" >
  
<!--
  
function  RightMenu()
  
{
    
this .AddExtendMenu = AddExtendMenu;
    
this .AddItem = AddItem;
    
this .GetMenu = GetMenu;
    
this .HideAll = HideAll;
    
this .I_OnMouseOver = I_OnMouseOver;
    
this .I_OnMouseOut = I_OnMouseOut;
    
this .I_OnMouseUp = I_OnMouseUp;
    
this .P_OnMouseOver = P_OnMouseOver;
    
this .P_OnMouseOut = P_OnMouseOut;
    A_rbpm 
=   new  Array();
    HTMLstr  
=   "" ;
    HTMLstr 
+=   " <!-- RightButton PopMenu -->\n " ;
    HTMLstr 
+=   " \n " ;
    HTMLstr 
+=   " <!-- PopMenu Starts -->\n " ;
    HTMLstr 
+=   " <div id='E_rbpm' class='rm_div'>\n " ;
                        
//  rbpm = right button pop menu
    HTMLstr  +=   " <table width='100%' border='0' cellspacing='0'>\n " ;
    HTMLstr 
+=   " <!-- Insert A Extend Menu or Item On Here For E_rbpm -->\n " ;
    HTMLstr 
+=   " </table>\n " ;
    HTMLstr 
+=   " </div>\n " ;
    HTMLstr 
+=   " <!-- Insert A Extend_Menu Area on Here For E_rbpm --> " ;
    HTMLstr 
+=   " \n " ;
    HTMLstr 
+=   " <!-- PopMenu Ends -->\n " ;
  }

  
function  AddExtendMenu(id,name,parent)
  
{
    
var  TempStr  =   "" ;

    eval(
" A_ " + parent + " .length++ " );
    eval(
" A_ " + parent + " [A_ " + parent + " .length-1] = id " );   //  将此项注册到父菜单项的ID数组中去
    TempStr  +=   " <div id='E_ " + id + " ' class='rm_div'>\n " ;
    TempStr 
+=   " <table width='100%' border='0' cellspacing='0'>\n " ;
    TempStr 
+=   " <!-- Insert A Extend Menu or Item On Here For E_ " + id + "  --> " ;
    TempStr 
+=   " </table>\n " ;
    TempStr 
+=   " </div>\n " ;
    TempStr 
+=   " <!-- Insert A Extend_Menu Area on Here For E_ " + id + "  --> " ;
    TempStr 
+=   " <!-- Insert A Extend_Menu Area on Here For E_ " + parent + "  --> " ;
    HTMLstr 
=  HTMLstr.replace( " <!-- Insert A Extend_Menu Area on Here For E_ " + parent + "  --> " ,TempStr);
    
    eval(
" A_ " + id + "  = new Array() " );
    TempStr  
=   "" ;
    TempStr 
+=   " <!-- Extend Item : P_ " + id + "  -->\n " ;
    TempStr 
+=   " <tr id='P_ " + id + " ' class='out' " ;
    TempStr 
+=   "  onmouseover='P_OnMouseOver(\ "" +id+ " \ " ,\ "" +parent+ " \ " )' " ;
    TempStr 
+=   "  onmouseout='P_OnMouseOut(\ "" +id+ " \ " ,\ "" +parent+ " \ " )' " ;
    TempStr 
+=   "  onmouseup=window.event.cancelBubble=true; " ;
    TempStr 
+=   "  onclick=window.event.cancelBubble=true; " ;
    TempStr 
+=   " ><td nowrap> " ;
    TempStr 
+=   "    " + name + "    </td><td style='font-family: webdings; text-align: ;'>4 " ;
    TempStr 
+=   " </td></tr>\n " ;
    TempStr 
+=   " <!-- Insert A Extend Menu or Item On Here For E_ " + parent + "  --> " ;
    HTMLstr 
=  HTMLstr.replace( " <!-- Insert A Extend Menu or Item On Here For E_ " + parent + "  --> " ,TempStr);
  }

  
function  AddItem(id,name,parent,location)
  
{
    
var  TempStr  =   "" ;
    
var  ItemStr  =   " <!-- ITEM : I_ " + id + "  --> " ;
    
if (id  ==   " sperator " )
    
{
      TempStr 
+=  ItemStr + " \n " ;
      TempStr 
+=   " <tr class='out' onclick='window.event.cancelBubble=true;' onmouseup='window.event.cancelBubble=true;'><td colspan='2' height='1'><hr class='sperator'></td></tr> " ;
      TempStr 
+=   " <!-- Insert A Extend Menu or Item On Here For E_ " + parent + "  --> " ;
      HTMLstr 
=  HTMLstr.replace( " <!-- Insert A Extend Menu or Item On Here For E_ " + parent + "  --> " ,TempStr);
      
return ;
    }

    
if (HTMLstr.indexOf(ItemStr)  !=   - 1 )
    
{
      alert(
" I_ " + id + " already exist! " );
      
return ;
    }

    TempStr 
+=  ItemStr + " \n " ;
    TempStr 
+=   " <tr id='I_ " + id + " ' class='out' " ;
    TempStr 
+=   "  onmouseover='I_OnMouseOver(\ "" +id+ " \ " ,\ "" +parent+ " \ " )' " ;
    TempStr 
+=   "  onmouseout='I_OnMouseOut(\ "" +id+ " \ " )' " ;
    TempStr 
+=   "  onclick='window.event.cancelBubble=true;' " ;
    
if (location  ==   null )
      TempStr 
+=   "  onmouseup='I_OnMouseUp(\ "" +id+ " \ " ,\ "" +parent+ " \ " ,null)' " ;
    
else
      TempStr 
+=   "  onmouseup='I_OnMouseUp(\ "" +id+ " \ " ,\ "" +parent+ " \ " ,\ "" +location+ " \ " )' " ;
    TempStr 
+=   " ><td nowrap> " ;
    TempStr 
+=   "    " + name + "    " ;
    TempStr 
+=   " </td><td></td></tr>\n " ;
    TempStr 
+=   " <!-- Insert A Extend Menu or Item On Here For E_ " + parent + "  --> " ;
    HTMLstr 
=  HTMLstr.replace( " <!-- Insert A Extend Menu or Item On Here For E_ " + parent + "  --> " ,TempStr);
  }

  
function  GetMenu()
  
{
    
return  HTMLstr;
  }

  
function  I_OnMouseOver(id,parent)
  
{
    
var  Item;
    
if (parent  !=   " rbpm " )
    
{
      
var  ParentItem;
      ParentItem 
=  eval( " P_ " + parent);
      ParentItem.className
= " over " ;
    }

    Item 
=  eval( " I_ " + id);
    Item.className
= " over " ;
    HideAll(parent,
1 );
  }

  
function  I_OnMouseOut(id)
  
{
    
var  Item;
    Item 
=  eval( " I_ " + id);
    Item.className
= " out " ;
  }

  
function  I_OnMouseUp(id,parent,location)
  
{
    
var  ParentMenu;
    window.event.cancelBubble
= true ;
    OnClick();
    ParentMenu 
=  eval( " E_ " + parent);
    ParentMenu.display
= " none " ;
    
if (location  ==   null )
      eval(
" Do_ " + id + " () " );
    
else
      window.open(location);
  }

  
function  P_OnMouseOver(id,parent)
  
{
    
var  Item;
    
var  Extend;
    
var  Parent;
    
if (parent  !=   " rbpm " )
    
{
      
var  ParentItem;
      ParentItem 
=  eval( " P_ " + parent);
      ParentItem.className
= " over " ;
    }

    HideAll(parent,
1 );
    Item 
=  eval( " P_ " + id);
    Extend 
=  eval( " E_ " + id);
    Parent 
=  eval( " E_ " + parent);
    Item.className
= " over " ;
    Extend.style.display
= " block " ;
    Extend.style.posLeft
= document.body.scrollLeft + Parent.offsetLeft + Parent.offsetWidth - 4 ;
    
if (Extend.style.posLeft + Extend.offsetWidth  >  document.body.scrollLeft + document.body.clientWidth)
        Extend.style.posLeft
= Extend.style.posLeft - Parent.offsetWidth - Extend.offsetWidth + 8 ;
    
if (Extend.style.posLeft  <   0 ) Extend.style.posLeft = document.body.scrollLeft + Parent.offsetLeft + Parent.offsetWidth;
    Extend.style.posTop
= Parent.offsetTop + Item.offsetTop;
    
if (Extend.style.posTop + Extend.offsetHeight  >  document.body.scrollTop + document.body.clientHeight)
      Extend.style.posTop
= document.body.scrollTop + document.body.clientHeight - Extend.offsetHeight;
    
if (Extend.style.posTop  <   0 ) Extend.style.posTop = 0 ;
  }

  
function  P_OnMouseOut(id,parent)
  
{
  }

  
function  HideAll(id,flag)
  
{
    
var  Area;
    
var  Temp;
    
var  i;
    
if ( ! flag)
    
{
      Temp 
=  eval( " E_ " + id);
      Temp.style.display
= " none " ;
    }

    Area 
=  eval( " A_ " + id);
    
if (Area.length)
    
{
      
for (i = 0 ; i  <  Area.length; i ++ )
      
{
        HideAll(Area[i],
0 );
        Temp 
=  eval( " E_ " + Area[i]);
        Temp.style.display
= " none " ;
        Temp 
=  eval( " P_ " + Area[i]);
        Temp.className
= " out " ;
      }

    }

  }




  
// document.onmouseup=OnMouseUp;
  document.onclick = OnClick;
  
function  OnMouseUp()
  

    
if (window.event.button  ==   0 )
    
{
      
var  PopMenu;
      PopMenu 
=  eval( " E_rbpm " );
      HideAll(
" rbpm " , 0 );
      PopMenu.style.display
= " block " ;
      PopMenu.style.posLeft
= document.body.scrollLeft + window.event.clientX;
      PopMenu.style.posTop
= document.body.scrollTop + window.event.clientY;
      
if (PopMenu.style.posLeft + PopMenu.offsetWidth  >  document.body.scrollLeft + document.body.clientWidth)
        PopMenu.style.posLeft
= document.body.scrollLeft + document.body.clientWidth - PopMenu.offsetWidth;
      
if (PopMenu.style.posLeft  <   0 ) PopMenu.style.posLeft = 0 ;
      
if (PopMenu.style.posTop + PopMenu.offsetHeight  >  document.body.scrollTop + document.body.clientHeight)
        PopMenu.style.posTop
= document.body.scrollTop + document.body.clientHeight - PopMenu.offsetHeight;
      
if (PopMenu.style.posTop  <   0 ) PopMenu.style.posTop = 0 ;
    }

  }

  
function  OnClick()
  

    HideAll(
" rbpm " , 0 );
  }

  
//  Add Your Function on following
   function  Do_viewcode() {window.location = " view-source: " + window.location.href;}
  
function  Do_help() {window.showHelp(window.location);}
  
function  Do_exit()  {window.close();}
  
function  Do_refresh()  {window.location.reload();}
  
function  Do_back()  {history.back();}
  
function  Do_forward()  {history.forward();}
  
  
-->
  
</ script >
  
< script  language ="JavaScript" >
  
<!--
  
var  menu  =   new  RightMenu();
menu.AddExtendMenu(
" d_setting " , " &nbsp;增加 " , " rbpm " );
menu.AddItem(
" Do_author " , " 增加行 " , " d_setting " , "" );
menu.AddItem(
" ca_yesky2 " , " 增加列 " , " d_setting " , " http://www.cctv.com " );

menu.AddExtendMenu(
" range_icon " , " &nbsp;删除 " , " rbpm " );
menu.AddItem(
" setico1 " , " 删除行 " , " range_icon " , null );
menu.AddItem(
" setico2 " , " 删除列 " , " range_icon " , null );

menu.AddExtendMenu(
" t_icon " , " &nbsp;合并 " , " rbpm " );
menu.AddItem(
" t_icon1 " , " 合并行 " , " t_icon " , null );
menu.AddItem(
" t_icon2 " , " 合并列 " , " t_icon " , null );

menu.AddItem(
" refresh " , " &nbsp;刷新 " , " rbpm " , null );
menu.AddItem(
" sperator " , "" , " rbpm " , null );
menu.AddItem(
" phase " , " &nbsp;<font disabled>粘贴</font>&nbsp;&nbsp;CTRL+Z " , " rbpm " , null );
menu.AddItem(
" folder_pro " , " &nbsp;属性 " , " rbpm " , null );
document.writeln(menu.GetMenu());
  
-->
</ script >
< table  id ="dataTable"  border ="0"  cellspacing ="1"  cellpadding ="1"  bgcolor ="#000000"  align ="center" >
< tr >
< td  bgcolor ="#F0F0F0"  width =""  height ="21"  align ="center" > &nbsp; </ td >
< td  bgcolor ="#ffffff"  width =""  height ="21" >< input  type ="text"  value ="01"  style ='text-align:center;border:none;background-color:#f0f0f0;'size='8'  oncontextmenu  = "OnMouseUp();" ></ td >
</ tr >
< tr >
< td  bgcolor ="#ffffff"  width =""  height ="21" >< input  type ="text"  value ="10"  style ='text-align:center;border:none;background-color:#f0f0f0;'size='8'  oncontextmenu  = "OnMouseUp();" ></ td >
< td  bgcolor ="#ffffff"  width =""  height ="21" >< input  type ="text"  value ="11"  style ='text-align:right;border:none;'size='8'  oncontextmenu  = "OnMouseUp();" ></ td >
</ tr >
</ table >
</ BODY >
</ HTML >


<% @ page contentType = " text/html; charset=GBK "  pageEncoding = " GBK " %>
< HTML >< HEAD >< TITLE > mouse-menu </ TITLE >
< META  content ="text/html; charset=gb2312"  http-equiv =Content-Type >
< META  content ="MSHTML 5.00.2614.3500"  name =GENERATOR >
< META  content =FrontPage.Editor.Document  name =ProgId >
< STYLE > .menutable  {
        BACKGROUND-COLOR
:  #ffffff ;  BORDER-BOTTOM :  #307ce8 1px solid ;  BORDER-LEFT :  #307ce8 5px solid ;  BORDER-RIGHT :  #307ce8 1px solid ;  BORDER-TOP :  #94bcf3 1px solid ;  FONT-SIZE :  12px ;  POSITION :  absolute ;  Z-INDEX :  100
}

.menutrin 
{
        BACKGROUND-COLOR
:  #1a71e6 ;  COLOR :  #ffffff ;  CURSOR :  hand
}

.menutrout 
{
        COLOR
:  #000000 ;  CURSOR :  hand
}

.menutd0 
{
        HEIGHT
:  25px ;  TEXT-ALIGN :  center ;  WIDTH :  28px ;  改变这个修改菜单高度---> :  
}

.menutd1 
{
        FONT-FAMILY
:  Webdings ;  TEXT-ALIGN :  right ;  WIDTH :  46px
}

.linktd1 
{
        WIDTH
:  46px
}

.menutd2 
{
        WIDTH
:  4px
}

.menuhr 
{
        BORDER-BOTTOM
:  #307ce8 1px inset ;  BORDER-LEFT :  #307ce8 1px inset ;  BORDER-RIGHT :  #307ce8 1px inset ;  BORDER-TOP :  #307ce8 1px inset
}

</ STYLE >
< BGSOUND  id =theBS  loop =0  src ="" ></ HEAD >
< BODY  bgColor =#eaf5fd  style ="FONT-SIZE: 10pt" >
< SCRIPT > <!----

/* -----------------------------------------------------------
鼠标右键菜单 1.0 Designed By Stroll  e-mail: csy-163@163.com



--------------------------------------------------------------
*/


// ---------------  有关数据 -----------------//

var  IconList  =   new  Array();    //  icon图片 集合, 下标从 1 开始

        IconList[
1 =   new  Image();
        
        IconList[
1 ].src  =   " images/icon_host.gif " ;
        
        IconList[
2 =   new  Image();
        
        IconList[
2 ].src  =   " images/icon_ip.gif " ;

        IconList[
3 =   new  Image();
        
        IconList[
3 ].src  =   " images/icon_mailbody.gif " ;        
        
        IconList[
4 =   new  Image();
        
        IconList[
4 ].src  =   " images/icon_mailer.gif " ;        

// ----------------  检测变量 菜单的显示隐藏就靠它了!!!  ------------------//        

var  JustMenuID  =   "" ;

var  SubMenuList  =   new  Array();

var  NowSubMenu  =   "" ;        

var  mouseCanSound  =   true ;           // ---------------------------  声音开关 ------  声音开关 ------------------//

var  menuSpeed      =    50 ;    // ---------- 菜单显示速度 ------------//

var  alphaStep      =    30 ;    // ---------- Alpaha 变化 度 -----------//
        
// ------------- 构建 主菜单 对象 -------------//

function  MouseMenu(objName)
{
        
this .id            =   " Menu_ " + objName;
        
this .obj           =  objName;
        
this .length   =   0 ;
        
        
        
this .addMenu  =  addMenu;
        
this .addLink  =  addLink;
        
this .addHR    =  addHR;        
        
        JustMenuID 
=   this .id;
        
        document.body.insertAdjacentHTML('beforeEnd','
< table id = " '+this.id+' "  border = " 0 "  cellspacing = " 0 "  cellpadding = " 0 "  style = " top: 0; left: 0; visibility: hidden; filter:Alpha(Opacity=0); "  class = " menutable "  onmousedown = event.cancelBubble = true ; onmouseup = event.cancelBubble = true ></ table > ');
}


// ----------- 构建 子菜单 对象 -------------//

function  SubMenu(objName,objID)
{
        
this .obj  =  objName;
        
this .id   =  objID;

        
this .addMenu  =  addMenu;
        
this .addLink  =  addLink;
        
this .addHR    =  addHR;

        
this .length   =   0 ;
}



// -------------- 生成 菜单 makeMenu 方法 -----------//
function  makeMenu(subID,oldID,word,icon,url,target,thetitle)
{
        
var  thelink  =  '';
        

        
if (icon && icon != "" )
        
{
                icon 
=  ' < img border = " 0 "  src = " '+IconList[icon].src+' " > ';
        }

        
else
        
{
                icon 
=  '';
        }

        
        
if ( ! thetitle || thetitle == "" )
        
{
                thetitle 
=  '';
        }

        
        
        
if (url && url != "" )
        
{
                thelink 
+=  ' < a href = " '+url+' "  ';
                
                
if (target && target != "" )
                
{
                        thelink 
+=  '  ';
                        thelink 
+=  'target = " '+target+' "  '
                }

                
                thelink 
+=  ' ></ a > ';
        }

        
        
var  Oobj  =  document.getElementById(oldID);

        
/* --------------------------------------------- 菜单html样式
        
          <tr class="menutrout" id="trMenu_one_0" title="I am title">
      <td class="menutd0"><img src="icon/sub.gif" border="0" width="16" height="16"></td>
      <td><a href="javascript:alert('I am menu');" target="_self"></a><nobr>菜单一</nobr></td>
      <td class="menutd1">4</td>
      <td class="menutd2">&nbsp;</td>
    </tr>

        
        --------------------------------------------------
*/

        
        Oobj.insertRow();
        

        
with (Oobj.rows(Oobj.rows.length - 1 ))
        
{
                id                         
=   " tr " + subID;
                className        
=   " menutrout " ;
                
                title       
=  thetitle;

        }

        
        eventObj 
=   " tr " + subID;
        
        eval(eventObj
+ '.attachEvent( " onmouseover " ,MtrOver(' + eventObj + '))');        
        eval(eventObj
+ '.attachEvent( " onclick " ,MtrClick(' + eventObj + '))');        
                
        
var  trObj  =  eval(eventObj);

        
for (i = 0 ;i < 4 ;i ++ )
        
{
                trObj.insertCell();
        }


        
with (Oobj.rows(Oobj.rows.length - 1 ))
        
{
                cells(
0 ).className  =   " menutd0 " ;
                cells(
0 ).innerHTML  =  icon;

                cells(
1 ).innerHTML  =  thelink + ' < nobr class = indentWord > ' + word + ' </ nobr > ';
                cells(
1 ).calssName  =   " indentWord "
                
                cells(
2 ).className  =   " menutd1 " ;
                cells(
2 ).innerHTML  =   " 4 " ;
                
                cells(
3 ).className  =   " menutd2 " ;
                cells(
3 ).innerText  =   "   " ;
                
        }
        
        
        
        
        document.body.insertAdjacentHTML('beforeEnd','
< table id = " '+subID+' "  border = " 0 "  cellspacing = " 0 "  cellpadding = " 0 "  style = " top: 0; left: 0; visibility: hidden; filter:Alpha(Opacity=0); "  class = " menutable "  onmousedown = event.cancelBubble = true ; onmouseup = event.cancelBubble = true ></ table > ');
        
        
                
}



// ---------------- 生成连接 makeLink 方法 ------------//
function  makeLink(subID,oldID,word,icon,url,target,thetitle)
{
        
        
        
var  thelink  =  '';
        
        
if (icon && icon != "" )
        
{
                icon 
=  ' < img border = " 0 "  src = " '+IconList[icon].src+' " > ';
        }

        
else
        
{
                icon 
=  '';
        }

        
        
if ( ! thetitle || thetitle == "" )
        
{
                thetitle 
=  '';
        }

        
        
        
if (url && url != "" )
        
{
                thelink 
+=  ' < a href = " '+url+' "  ';
                
                
if (target && target != "" )
                
{
                        thelink 
+=  '  ';
                        thelink 
+=  'target = " '+target+' "  '
                }

                
                thelink 
+=  ' ></ a > ';
        }

        
        
var  Oobj  =  document.getElementById(oldID);
        
        
        
/* --------------------------------------------- 连接html样式
        
          <tr class="menutrout" id="trMenu_one_0" title="I am title">
      <td class="menutd0"><img src="icon/sub.gif" border="0" width="16" height="16"></td>
      <td><a href="javascript:alert('I am link');" target="_self"></a><nobr>连接一</nobr></td>
      <td class="linktd1"></td>
      <td class="menutd2">&nbsp;</td>
    </tr>

        
        --------------------------------------------------
*/
        
        
        Oobj.insertRow();
        

        
with (Oobj.rows(Oobj.rows.length - 1 ))
        
{
                id                         
=   " tr " + subID;
                className        
=   " menutrout " ;                
                title       
=  thetitle;

        }

        
        eventObj 
=   " tr " + subID;
        
        eval(eventObj
+ '.attachEvent( " onmouseover " ,LtrOver(' + eventObj + '))');        
        eval(eventObj
+ '.attachEvent( " onmouseout " ,LtrOut(' + eventObj + '))');                
        eval(eventObj
+ '.attachEvent( " onclick " ,MtrClick(' + eventObj + '))');        
                
        
var  trObj  =  eval(eventObj);

        
for (i = 0 ;i < 4 ;i ++ )
        
{
                trObj.insertCell();
        }


        
with (Oobj.rows(Oobj.rows.length - 1 ))
        
{
                cells(
0 ).className  =   " menutd0 " ;
                cells(
0 ).innerHTML  =  icon;

                cells(
1 ).innerHTML  =  thelink + ' < nobr class = indentWord > ' + word + ' </ nobr > ';

                cells(
2 ).className  =   " linktd1 " ;
                cells(
2 ).innerText  =   "   " ;
                
                cells(
3 ).className  =   " menutd2 " ;
                cells(
3 ).innerText  =   "   " ;
                
        }
        

}



// -------------- 菜单对象 addMenu 方法 ------------//
function  addMenu(word,icon,url,target,title)
{
        
var  subID     =   this .id  +   " _ "   +   this .length;
        
var  subObj   =   this .obj + " [ " + this .length + " ] " ;
        
        
var  oldID    =   this .id;
        
        eval(subObj
+ " = new SubMenu(' " + subObj + " ',' " + subID + " ') " );
        
         makeMenu(subID,oldID,word,icon,url,target,title);
         
         
this .length ++ ;
        
}



// ------------- 菜单对象 addLink 方法 -------------//
function  addLink(word,icon,url,target,title)
{
        
var  subID     =   this .id  +   " _ "   +   this .length;
        
var  oldID   =   this .id;
        
         makeLink(subID,oldID,word,icon,url,target,title);
         
         
this .length ++ ;        
}


// ------------ 菜单对象 addHR 方法 -----------------//
function  addHR()
{
        
var  oldID  =   this .id;

        
var  Oobj  =  document.getElementById(oldID);
        
        Oobj.insertRow();
        
        
/* ------------------------------------------
        
         <tr>
      <td colspan="4">
                <hr class="menuhr" size="1" width="95%">
       </td>
    </tr>
        
        --------------------------------------------
*/
        

        
        Oobj.rows(Oobj.rows.length
- 1 ).insertCell();

        
with (Oobj.rows(Oobj.rows.length - 1 ))
        
{
                cells(
0 ).colSpan =   4 ;
                cells(
0 ).insertAdjacentHTML('beforeEnd',' < hr class = " menuhr "  size = " 1 "  width = " 95% " > ');                
        }
        
        
}







// --------- MtrOver(obj)-------------------//
function  MtrOver(obj)
{
        
return  sub_over;
        
        
function  sub_over()
        
{
        
                
var  sonid  =  obj.id.substring( 2 ,obj.id.length);
                
                
var  topobj  =  obj.parentElement.parentElement; 
                
                NowSubMenu 
=  topobj.id;
                
                
if (obj.className == " menutrout " )
                
{
                        mouseWave();
                }
                
                
                HideMenu(
1 );                
                
                SubMenuList[returnIndex(NowSubMenu)] 
=  NowSubMenu;

                ShowTheMenu(sonid,MPreturn(sonid))                
                
                SubMenuList[returnIndex(obj.id)] 
=  sonid;
                
                
if (topobj.oldTR)
                

                        eval(topobj.oldTR
+ '.className  =   " menutrout " '); 
                }
 

                obj.className 
=   " menutrin "

                topobj.oldTR 
=  obj.id; 
                

        }

}


// --------- LtrOver(obj)-------------------//
function  LtrOver(obj)
{
        
return  sub_over;
        
        
function  sub_over()
        
{
                
var  topobj  =  obj.parentElement.parentElement; 

                NowSubMenu 
=  topobj.id;
                
                HideMenu(
1 );
                
                SubMenuList[returnIndex(NowSubMenu)] 
=  NowSubMenu;
                                
                
if (topobj.oldTR)
                

                        eval(topobj.oldTR
+ '.className  =   " menutrout " '); 
                }
 

                obj.className 
=   " menutrin "

                topobj.oldTR 
=  obj.id; 

        }

}


// --------- LtrOut(obj)-------------------//
function  LtrOut(obj)
{
        
return  sub_out;
        
        
function  sub_out()
        
{
                
var  topobj  =  obj.parentElement.parentElement; 
                
                obj.className 
=   " menutrout "
                
                topobj.oldTR 
=   false
        }

}


// ----------MtrClick(obj)-----------------//

function  MtrClick(obj)
{
        
return  sub_click;
        
        
function  sub_click()
        
{
                
if (obj.cells( 1 ).all.tags( " A " ).length > 0 )
                
{
                        obj.cells(
1 ).all.tags( " A " )( 0 ).click();
                }
        

        }

}



// ---------- returnIndex(str)--------------//

function  returnIndex(str)
{
        
return  (str.split( " _ " ).length - 3 )
}



// ---------ShowTheMenu(obj,num)-----------------//

function  ShowTheMenu(obj,num)
{
        
var  topobj  =  eval(obj.substring( 0 ,obj.length - 2 ));
        
        
var  trobj   =  eval( " tr " + obj);
        
        
var  obj  =  eval(obj);
        
        
if (num == 0 )
        
{
                
with (obj.style)
                
{
                        pixelLeft 
=  topobj.style.pixelLeft  + topobj.offsetWidth;
                        pixelTop  
=  topobj.style.pixelTop  +  trobj.offsetTop;
                }

        }

        
if (num == 1 )
        
{
                
with (obj.style)
                
{
                        pixelLeft 
=  topobj.style.pixelLeft  +  topobj.offsetWidth;
                        pixelTop  
=  topobj.style.pixelTop   +  trobj.offsetTop  +  trobj.offsetHeight  -  obj.offsetHeight;
                }

        }

        
if (num == 2 )
        
{
                
with (obj.style)
                
{
                        pixelLeft 
=  topobj.style.pixelLeft  -   obj.offsetWidth;
                        pixelTop  
=  topobj.style.pixelTop  +  trobj.offsetTop;
                }
        
        }

        
if (num == 3 )
        
{
                
with (obj.style)
                
{
                        pixelLeft 
=  topobj.style.pixelLeft  -   obj.offsetWidth;
                        pixelTop  
=  topobj.style.pixelTop   +  trobj.offsetTop  +  trobj.offsetHeight  -  obj.offsetHeight;
                }
        
        }

        
        obj.style.visibility  
=   " visible " ;         
        
        
if (obj.alphaing)
        
{
                clearInterval(obj.alphaing);
        }

        
        obj.alphaing 
=  setInterval( " menu_alpha_up( " + obj.id + " , " + alphaStep + " ) " ,menuSpeed);        
}


// ----------HideMenu(num)-------------------//

/* ----------------------
var SubMenuList = new Array();

var NowSubMenu = "";        

---------------------
*/


function  HideMenu(num)
{
        
var  thenowMenu  =   "" ;
        
        
var  obj  =   null ;
        
        
if (num == 1 )
        
{
                thenowMenu 
=  NowSubMenu
        }

        
        
        
        
for (i = SubMenuList.length - 1 ;i >= 0 ;i -- )
        
{
                
if (SubMenuList[i] && SubMenuList[i] != thenowMenu)
                
{
                        
                        obj 
=  eval(SubMenuList[i]);
                        
                        
if (obj.alphaing)
                        
{
                                clearInterval(obj.alphaing);
                        }
        

                        obj.alphaing 
=  setInterval( " menu_alpha_down( " + obj.id + " , " + alphaStep + " ) " ,menuSpeed);
                        
                        obj.style.visibility 
=   " hidden " ;                
                        
                        eval(
" tr " + SubMenuList[i]).className  =   " menutrout " ;
                                                
                        SubMenuList[i] 
=   null ;        
                }

                
else
                
{
                        
if (SubMenuList[i] == thenowMenu)
                        
{
                                
return ;
                        }

                }

        }

        
        NowSubMenu 
=   "" ;
}





// -----------MainMenuPosition return()------------//

function  MMPreturn()
{
        
var  obj  =  eval(JustMenuID);
        
        
var  x  =  event.clientX;
        
var  y  =  event.clientY;
        
        
var  judgerX  =  x  +  obj.offsetWidth;
        
var  judgerY  =  y  +  obj.offsetHeight;

        
var  px  =   0 ;
        
var  py  =   0 ;
        
        
if (judgerX > document.body.clientWidth)
        
{
                px 
=   2 ;
        }

        
if (judgerY > document.body.clientHeight)
        
{
                py 
=   1 ;
        }

                
        
return  (px + py);
}


// -----------MenuPosition return(obj)--------------//

function  MPreturn(obj)
{
        
var  topobj  =  eval(obj.substring( 0 ,obj.length - 2 ));
        
        
var  trobj   =  eval( " tr " + obj);
        
        
var  x  =  topobj.style.pixelLeft  +  topobj.offsetWidth;
        
var  y  =  topobj.style.pixelTop   +  trobj.offsetTop;

        obj 
=  eval(obj);
        
        
var  judgerY  =   obj.offsetHeight  +  y;
        
var  judgerX  =   obj.offsetWidth   +  x;
        
        
var  py  =   0 ;
        
var  px  =   0 ;
        
        
if (judgerY >= document.body.clientHeight)
        
{
                py 
=   1 ;
        }

        
        
if (judgerX >=  document.body.clientWidth)
        
{
                px 
=   2 ;
        }
 
                        
        
return  (px + py);
}


// -----------mouseWave()-------------//

function  mouseWave()
{
        
if (mouseCanSound)
        
{
                theBS.src
=   " sound/sound.wav " ;
        }
        
}


// ----------- menu_alpha_down -------//

function  menu_alpha_down(obj,num)
{
                
var  obj  =  eval(obj);
                
                
if (obj.filters.Alpha.Opacity  >   0  )
                
{
                        obj.filters.Alpha.Opacity 
+=   - num;
                }
        
                
else
                
{        
                        clearInterval(obj.alphaing);
                        obj.filters.Alpha.Opacity 
=   0 ;
                        obj.alphaing 
=   false ;                        
                        obj.style.visibility 
=   " hidden " ;
                }
        
}



// ------------ menu_alpha_up --------//

function  menu_alpha_up(obj,num)
{
                
var  obj  =  eval(obj);
                
                
if (obj.filters.Alpha.Opacity < 100 )
                        obj.filters.Alpha.Opacity 
+=  num;
                
else
                
{        
                        clearInterval(obj.alphaing);
                        obj.filters.Alpha.Opacity 
=   100 ;
                        obj.alphaing 
=   false ;
                }
        
}



// ----------- IE ContextMenu -----------------//

function  document.oncontextmenu()
{
        
return   false ;
}



// ----------- IE Mouseup ----------------//

function  down()
{
        
if (event.button == 0 )
        
{
        
                HideMenu(
0 );
                

                
var  obj  =  eval(JustMenuID)
                
                
                        obj.style.visibility 
=   " hidden " ;
                        
                        
                        
if (obj.alphaing)
                        
{
                                clearInterval(obj.alphaing);
                        }

                        
                        obj.filters.Alpha.Opacity 
=   0 ;
                        
                        
var  judger  =  MMPreturn()
                        
                        
if (judger == 0 )
                        
{
                                
with (obj.style)
                                
{
                                        pixelLeft 
=  event.clientX  +  document.body.scrollLeft;
                                        pixelTop  
=  event.clientY  +  document.body.scrollTop;
                                }

                        }

                        
if (judger == 1 )
                        
{
                                
with (obj.style)
                                
{
                                        pixelLeft 
=  event.clientX  +  document.body.scrollLeft;
                                        pixelTop  
=  event.clientY  -  obj.offsetHeight  +  document.body.scrollTop;
                                }

                        }

                        
if (judger == 2 )
                        
{
                                
with (obj.style)
                                
{
                                        pixelLeft 
=  event.clientX  -  obj.offsetWidth  +  document.body.scrollLeft;
                                        pixelTop  
=  event.clientY  +  document.body.scrollTop;
                                }

                        }

                        
if (judger == 3 )
                        
{
                                
with (obj.style)
                                
{
                                        pixelLeft 
=  event.clientX  -  obj.offsetWidth  +  document.body.scrollLeft;
                                        pixelTop  
=  event.clientY  -  obj.offsetHeight  +  document.body.scrollTop;
                                }

                        }

                        
                        mouseWave();
                                                
                        obj.style.visibility 
=   " visible " ;
                        
                        obj.alphaing 
=  setInterval( " menu_alpha_up( " + obj.id + " , " + alphaStep + " ) " ,menuSpeed);

                
                
        }

}


// ---------- IE MouseDown --------------//

function  document.onmousedown()
{
        
if (event.button == 1 )
        
{
                HideMenu();
                
                
var  obj  =  eval(JustMenuID)
                
                
if (obj.alphaing)
                
{
                        clearInterval(obj.alphaing);
                }

                
                obj.alphaing 
=  setInterval( " menu_alpha_down( " + obj.id + " , " + alphaStep + " ) " ,menuSpeed);
                
        }

}

// ----->

</ SCRIPT >

< SCRIPT >
        
var  one  =   new  MouseMenu( " one " );
        
        one.addMenu(
" 菜单一 " , 1 , " javascript:alert('I am menu'); " , " _self " , " I am title " );
                one[
0 ].addLink( " 连接一 " , 2 , " javascript:alert('I am link') " );
                one[
0 ].addHR();
                one[
0 ].addLink( " 连接二 " , "" , " javascript:alert('I am link') " );               
                one[
0 ].addMenu( " 菜单三 " );
                        one[
0 ][one[ 0 ].length - 1 ].addLink( " 连接一 " , 1 , " javascript:; " );
                one[
0 ].addLink( " 连接三 " , "" , " javascript:alert('I am link') " );
                one[
0 ].addLink( " 连接四 " , "" , " javascript:alert('I am link') " );
        one.addLink(
" 连接二 " , "" , " javascript:alert('I am link') " );
        one.addMenu(
" 菜单二 " , 3 );
                one[
2 ].addLink( " 连接一 " , "" , " javascript:alert('I am link') " );
        one.addHR();
        one.addLink(
" 连接三,多长都可以 " , 4 , " javascript:alert('I am link') " );                          
</ SCRIPT >

< table  id ="dataTable"  border ="0"  cellspacing ="1"  cellpadding ="1"  bgcolor ="#000000"  align ="center" >
< tr >
< td  bgcolor ="#F0F0F0"  width =""  height ="21"  align ="center" > &nbsp; </ td >
< td  bgcolor ="#ffffff"  width =""  height ="21" >< input  type ="text"  value ="01"  style ='text-align:center;border:none;background-color:#f0f0f0;'size='8'  oncontextmenu  = "down();" ></ td >
</ tr >
< tr >
< td  bgcolor ="#ffffff"  width =""  height ="21" >< input  type ="text"  value ="10"  style ='text-align:center;border:none;background-color:#f0f0f0;'size='8'  oncontextmenu  = "down();" ></ td >
< td  bgcolor ="#ffffff"  width =""  height ="21" >< input  type ="text"  value ="11"  style ='text-align:right;border:none;'size='8'  oncontextmenu  = "down();" ></ td >
</ tr >
</ table >
</ BODY ></ HTML >



posted on 2009-06-04 17:19 JJCEA 阅读(4095) 评论(1)  编辑  收藏 所属分类: JS日记

FeedBack:
# re: js 鼠标右键菜单
2012-04-15 00:24 | saddle629
楼主,你这贴的代码太坑了啊,直接复制的话,代码格式不符合要求。
楼主你敢不敢给真正的源码给我一份,邮箱saddle629@sina.com  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: