下面是导航菜单的代码,JS程序是想要实现子菜单层TOP值与LEFT值
我在导航菜单顶部加了个只显示8秒的广告,页面加载的时候,子菜单直接在广告上显示了,因为子菜单是层,并且TOP值固定了,现在想实现有广告的时候改变TOP值,广告加载完后再调回TOP的值,请怎么用JS代码实现主菜单:
<a href="film.html" onmouseover="newload(1)" onmouseout="newclose(1)">热门电影</a>
...
<a href="TV.html" onmouseover="newload(5)" onmouseout="newclose(5)">热门电视剧</a>
===========================================================
子菜单:
document.writeln("<div id=\"Layer1\" class=\"h1 \">");
document.writeln("  <div id=\"ptop\">");
document.writeln(" <a href=\"\/movie\/list_26_1.html\">动作 |<\/a>");
document.writeln("  <\/div>");
document.writeln("<\/div>");
...
document.writeln("<div id=\"Layer5\" class=\"h1\">");
document.writeln("  <div id=\"ptop\">");
document.writeln(" <a href=\"\/movie\/list_34_1.html\"现代 |<\/a>");
document.writeln("  <\/div>");
document.writeln("<\/div>");
==================================================================
处理函数:
function  newload(num){
  for(var i=1;i<6;i++){
    if(i==num){
      document.getElementById('Layer'+num).className='h2';
      document.getElementById('Layer'+num).style.top=expression(document.documentElement.clientHeight-document.getElementById('Layer'+num).style.pixelHeight+document.body.scrollTop);
      document.getElementById('Layer'+num).style.left=(document.getElementById('Layer'+num).offsetLeft)+"px";
    }
  }
}
function newclose(num){
  for(var i=1;i<6;i++){
    if(i==num){document.getElementById('Layer'+num).className='h1';}
  }
}
======================================================================
CSS文件:
.h1{visibility:hidden;}
.h2{visibility:visible;}#Layer1{
  position:absolute; width:376px; height:39px; z-index:1; left: 390px; top: 23px;overflow:hidden;
}
...
#Layer5{
  position:absolute; width:330px; height:39px; z-index:1; left: 420px; top: 23px;overflow:hidden;
}
#ptop{padding-top:10px;padding-left:5px}
#ptop a{ display:block; width:36px; margin:0px; padding:0px 0px 0px 10px; float:left; clear:none;}