一些有用的javascript代码(1)

来源:互联网 发布:小说大纲制作软件 编辑:程序博客网 时间:2024/05/16 01:24

<HTML><HEAD>
<TITLE>下拉式菜单</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>A:link {
 COLOR: #333333; TEXT-DECORATION: none
}
A:active {
 COLOR: #333333; TEXT-DECORATION: none
}
A:visited {
 COLOR: #333333; TEXT-DECORATION: none
}
A:hover {
 COLOR: #ff6600
}
BODY {
 BACKGROUND-POSITION: center 50%; SCROLLBAR-FACE-COLOR: #c0c0c0; FONT-SIZE: 12px; BACKGROUND-IMAGE: url('Images/bg.gif'); SCROLLBAR-HIGHLIGHT-COLOR: #c0c0c0; SCROLLBAR-SHADOW-COLOR: #c0c0c0; COLOR: #333333; SCROLLBAR-3DLIGHT-COLOR: #e0e0e0; SCROLLBAR-ARROW-COLOR: #333333; SCROLLBAR-TRACK-COLOR: #e0e0e0; FONT-FAMILY: "宋体"; SCROLLBAR-DARKSHADOW-COLOR: #c0c0c0
}
TD {
 FONT-SIZE: 12px; LINE-HEIGHT: 15px; FONT-FAMILY: 宋体
}
TD.TableBody1 {
 BACKGROUND-COLOR: #ffffff
}
.tableBorder1 {
 BORDER-RIGHT: 1px; BORDER-TOP: 1px; BORDER-LEFT: 1px; WIDTH: 100%; BORDER-BOTTOM: 1px; BACKGROUND-COLOR: #c5bdc5
}
.table {
 BORDER-RIGHT: #333333 1px solid; BORDER-LEFT: #333333 1px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #ffffff
}
INPUT {
 BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 1px; PADDING-LEFT: 1px; BORDER-LEFT-WIDTH: 1px; FONT-SIZE: 9pt; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: #cccccc; PADDING-BOTTOM: 1px; BORDER-TOP-COLOR: #cccccc; PADDING-TOP: 1px; HEIGHT: 18px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: #cccccc
}
</STYLE>
<script Language="JavaScript">
 var h;
 var w;
 var l;
 var t;
 var topMar = 3;
 var leftMar = -10;
 var space = 2;
 var isvisible;
 var MENU_SHADOW_COLOR='#999999';
 var global = window.document
 global.fo_currentMenu = null
 global.fo_shadows = new Array

function HideMenu()
{
 var mX;
 var mY;
 var vDiv;
 var mDiv;
 if (isvisible == true)
{
  vDiv = document.all("menuDiv");
  mX = window.event.clientX + document.body.scrollLeft;
  mY = window.event.clientY + document.body.scrollTop;
  if ((mX < parseInt(vDiv.style.left)) || (mX > parseInt(vDiv.style.left)+vDiv.offsetWidth) || (mY < parseInt(vDiv.style.top)-h) || (mY > parseInt(vDiv.style.top)+vDiv.offsetHeight)){
   vDiv.style.visibility = "hidden";
   isvisible = false;
  }
}
}

function ShowMenu(vMnuCode,tWidth) {
 vSrc = window.event.srcElement;
 vMnuCode = "<table id='submenu' cellspacing=1 cellpadding=3 style='width:"+tWidth+"' class=tableborder1 onmouseout='HideMenu()'><tr height=23><td nowrap align=left class=tablebody1>" + vMnuCode + "</td></tr></table>";

 h = vSrc.offsetHeight;
 w = vSrc.offsetWidth;
 l = vSrc.offsetLeft + leftMar+4;
 t = vSrc.offsetTop + topMar + h + space-2;
 vParent = vSrc.offsetParent;
 while (vParent.tagName.toUpperCase() != "BODY")
 {
  l += vParent.offsetLeft;
  t += vParent.offsetTop;
  vParent = vParent.offsetParent;
 }

 menuDiv.innerHTML = vMnuCode;
 menuDiv.style.top = t;
 menuDiv.style.left = l;
 menuDiv.style.visibility = "visible";
 isvisible = true;
    makeRectangularDropShadow(submenu, MENU_SHADOW_COLOR, 4)
}

function makeRectangularDropShadow(el, color, size)
{
 var i;
 for (i=size; i>0; i--)
 {
  var rect = document.createElement('div');
  var rs = rect.style
  rs.position = 'absolute';
  rs.left = (el.style.posLeft + i) + 'px';
  rs.top = (el.style.posTop + i) + 'px';
  rs.width = el.offsetWidth + 'px';
  rs.height = el.offsetHeight + 'px';
  rs.zIndex = el.style.zIndex - i;
  rs.backgroundColor = color;
  var opacity = 1 - i / (i + 1);
  rs.filter = 'alpha(opacity=' + (100 * opacity) + ')';
  el.insertAdjacentElement('afterEnd', rect);
  global.fo_shadows[global.fo_shadows.length] = rect;
 }
}
var About= '&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"About.asp/"><font color="#000000">公 司 简 介</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Culture.asp/"><font color="#000000">公 司 文 化</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Organize.asp/"><font color="#000000">组 织 机 构</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Principle.asp/"><font color="#000000">精 神 理 念</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Contact.asp/"><font color="#000000">联 系 我 们</font></a>&nbsp;'
var News= '&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"News.asp/"><font color="#000000">企 业 新 闻</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"yeNews.asp/"><font color="#000000">业 内 资 讯</font></a>&nbsp;'
var Product= '&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Product.asp/"><font color="#000000">产 品 展 示</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Products.asp/"><font color="#000000">产 品 分 类</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"search.asp/"><font color="#000000">产 品 搜 索</font></a>&nbsp;'
var Job= '&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Job.asp/"><font color="#000000">人 才 招 聘</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Jobs.asp/"><font color="#000000">人 才 策 略</font></a>&nbsp;'
var sale= '&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Sale.asp/"><font color="#000000">国 内 市 场</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Salea.asp/"><font color="#000000">国 外 市 场</font></a>&nbsp;'
var server= '&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Server.asp/"><font color="#000000">会 员 中 心</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"NetBook.asp/"><font color="#000000">留 言 中 心</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"E_shop.asp/"><font color="#000000">订 单 查 询</font></a>&nbsp;'
var index= '&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"default.asp/"><font color="#000000">网 站 首 页</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Index.asp/"><font color="#000000">企业形象页</font></a>&nbsp;'
var img= '&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Honor.asp/"><font color="#000000">企 业 荣 誉</font></a>&nbsp;<br>&nbsp;<a style=font-size:9pt;line-height:14pt; href=/"Img.asp/"><font color="#000000">企 业 形 象</font></a>&nbsp;'
</script>
<BODY bgColor=#000000 leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onmousemove="HideMenu()" style="background-image: url('Img/bg0.gif'); background-attachment: fixed">
<div id=menuDiv style='Z-INDEX: 2; VISIBILITY: hidden; WIDTH: 1px; POSITION: absolute; HEIGHT: 1px; BACKGROUND-COLOR: #9cc5f8'></div>
<TABLE width="760" border=0 align="center" cellPadding=0 cellSpacing=0 bgcolor="#FFFFFF">
  <TBODY>
    <TR>
      <TD bgColor=#f2f2f2 width="762">
  </TD>
    </TR>
    <TR>
      <TD height=32 background="Img/head_bg1.gif" width="760">
        <TABLE cellSpacing=0 cellPadding=0 width="94%" border=0>
          <TBODY>
            <TR>
              <TD width="9%"> </TD>
              <TD width="91%" valign="bottom"><IMG height=27
            src="Img/head_bg1.gif" width=2
            align=absMiddle><a href="default.asp" onMouseOver='ShowMenu(index)'> 首 页</a> <IMG height=27
            src="Img/head_bg1.gif" width=2
            align=absMiddle> <a href="About.asp" onMouseOver='ShowMenu(About)'>企业简介</a> <IMG height=27
            src="Img/head_bg1.gif" width=2
            align=absMiddle> <a href="News.asp" onMouseOver='ShowMenu(News)'>新闻资讯</a> <IMG height=27
            src="Img/head_bg1.gif" width=2
            align=absMiddle> <a href="Product.asp" onMouseOver='ShowMenu(Product)'>产品展示</a> <IMG height=27
            src="Img/head_bg1.gif" width=2
            align=absMiddle> <a href="Honor.asp" onMouseOver='ShowMenu(img)'>企业荣誉</a> <IMG height=27
            src="Img/head_bg1.gif" width=2
            align=absMiddle> <a onMouseOver="ShowMenu(sale)" href="netsale">营销网络</a> <IMG height=27
            src="Img/head_bg1.gif" width=2
            align=absMiddle> <a href="Job.asp" onMouseOver='ShowMenu(Job)'>人才招聘</a> <IMG height=27
            src="Img/head_bg1.gif" width=2
            align=absMiddle> <a href="Went.asp">信息反馈</a> <IMG height=27
            src="Img/head_bg1.gif" width=2
            align=absMiddle> <a href="Server.asp" onMouseOver='ShowMenu(server)'>客户服务</a></TD>
            </TR>
          </TBODY>
        </TABLE>
      </TD>
    </TR>
  </TBODY>
</TABLE>

原创粉丝点击