浮动层的制作

来源:互联网 发布:高校邦网络课程答案 编辑:程序博客网 时间:2024/06/11 10:41

今天终于连抄带蒙把人家鼠标移过某个区域时,显示浮动框文字的代码给整了过来:

首先:

<script language="JavaScript1.2">

function MM_findObj(n, d) {

  var p,i,x;

  if(!d) d=document;

  if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document;

    n=n.substring(0,p);

  }

  if(!(x=d[n])&&d.all) x=d.all[n];

  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++)

    x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n);

  return window.hintDiv;

 

}

 

function MM_setTextOfLayer(objName,x,newText) {

  newText = "<TABLE WIDTH=100% BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR=/"#456972/"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0><TR><TD ALIGN = /"CENTER/" BGCOLOR=/"#FFFFFF/"><FONT FACE=/"宋体/" COLOR=/"#8A2BE2/">"+newText+"</FONT></TD></TR></TABLE></TD></TR></TABLE>"

  if ((obj=MM_findObj(objName))!=null) with (obj)

 

    if (document.layers) {

      document.write(unescape(newText));

      document.close();

    }

    else innerHTML = unescape(newText);

}

 

function MM_showHideLayers() {

  var i,p,v,obj,args=MM_showHideLayers.arguments;

  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];

    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }

    obj.visibility=v; }

}

 

function MM_changeProp(objName,x,theProp,theValue) { //v6.0

  var obj = MM_findObj(objName);

  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){

    if (theValue == true || theValue == false)

      eval("obj."+theProp+"="+theValue);

    else eval("obj."+theProp+"='"+theValue+"'");

  }

}

 

//-->

</script>

然后在页面上加入层:

<DIV id=hintDiv style="POSITION: absolute; Z-INDEX: 0; left: 0px; top: 17px; width: 500px; height: 100px;visibility: hidden;" ></DIV>

最后,在调用的地方写:

  <TR onMouseOver=" MM_setTextOfLayer('overDiv','','<%=strShowText%>');MM_showHideLayers('overDiv','','show');

                            MM_changeProp('overDiv','','style.left',0,'DIV');MM_changeProp('overDiv','','style.top',window.event.y+10,'DIV');

                            MM_changeProp('overDiv','','style.width',<%=intLength%>*13,'DIV');" onMouseOut=" MM_showHideLayers('overDiv','','hide');">

此事多仗胡兄相助,小女子在此敛衽为礼,聊表谢意!