本帖最后由 RixTox 于 2011-04-10 18:17:04 编辑

解决方案 »

  1.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD><TITLE>Menu</TITLE>
    <SCRIPT language=javascript type=text/javascript></SCRIPT>
    <META http-equiv=Content-Type content="text/html; charset=gb2312"><META content="Microsoft FrontPage 4.0" name=GENERATOR>
    <STYLE type=text/css>
    #nothing {
    VISIBILITY: visible
    }
    .box {
        height:0px;
        margin:0px auto;
        overflow:hidden;
        border: 0px solid #FFF;
        background: #000000;
    text-align: center;
    font-size: 12px;
    font-family: "tahoma";
    color: #008000;
    }
    .Sub {
        text-align: center;
    font-size: 12px;
    font-family: "tahoma";
    color: #008000;
    }
    .Menu {
    font-size: 20px;
    font-family: "tahoma";
    color: #008000;
    }
    .Main {
    font-size: 15px;
    font-family: "tahoma";
    color: #008000;
    }
    </STYLE>
    </HEAD>
    <BODY text=#00ff00 vLink=#008000 aLink=#008000 link=#008000 bgColor=#000000 
    background="" onload=writetext();>
    <p>
    <SCRIPT language=javascript> //-------------------------
    //   Written By RixTox
    //-------------------------function Is() {   // Check the version of the Internet Explorer and the type of the IE decode energy it uses var agent = navigator.userAgent.toLowerCase(); this.major = parseInt(navigator.appVersion); this.minor = parseFloat(navigator.appVersion); this.ns = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1))); this.ns2 = (this.ns && (this.major == 2)); this.ns3 = (this.ns && (this.major == 3)); this.ns4b = (this.ns && (this.major == 4) && (this.minor <= 4.03)); this.ns4 = (this.ns && (this.major >= 4)); this.ie = (agent.indexOf("msie") != -1); this.ie3 = (this.ie && (this.major == 2)); this.ie4 = (this.ie && (this.major >= 4)); this.op3 = (agent.indexOf("opera") != -1); } var is = new Is()  // Check out the versionif(is.ns4) {  // Accroding to the result of the checking, set the suitable options for use laterdoc = "document"; sty = ""; htm = ".document" } else if(is.ie4) { doc = "document.all"; sty = ".style"; htm = "" } var text1 = "", text2 = "", line = 0, count = 0, count2=0, linefirst = 1;  // Set up quantities for text saving and countingmsg = new Array(); // Set the text of each line of contents li1 = new Array();li2 = new Array();linkurl = new Array();li1[line] = "<center><span class=Menu>";
    msg[line] = "Menu"; 
    li2[line] = "</span></center>";
    linkurl[line] = "";
    line += 1;li1[line] = "<center><span class=Main><a href=# onClick=usefuction('"+line+"') onfocus=this.blur();>";
    msg[line] = "Index"; 
    li2[line] = "</a></span></center>";
    linkurl[line] = "Maindex.htm";
    line += 1;li1[line] = "<center><span class=Main><a id='Group1' onfocus='this.blur()' href=# onclick=divname='box1';subdivname='cont1';NextNumber=1;if(isOpen[NextNumber]!=1){isOpen[NextNumber]=0};extend();>";
    msg[line] = "Title2"; 
    li2[line] = "</a></span></center><p></p><div class='box' id='box1'><div id='cont1'><p>测试..测试.</p><p>再次测试..</p><p>测试下拉效果</p></div></div>";
    linkurl[line] = "";
    line += 1;li1[line] = "<center><span class=Main><a id='Group2' onfocus='this.blur()' href=# onclick=divname='box2';subdivname='cont2';NextNumber=2;if(isOpen[NextNumber]!=1){isOpen[NextNumber]=0};extend();>";
    msg[line] = "Title3"; 
    li2[line] = "</a></span></center><p></p><div class='box' id='box2'><div id='cont2'><p>测试..测试.</p><p>再次测试..</p><p>测试下拉效果</p></div></div>";
    linkurl[line] = "";
    line += 1;li1[line] = "<center><span class=Main><a id='Group3' onfocus='this.blur()' href=# onclick=divname='box3';subdivname='cont3';NextNumber=3;if(isOpen[NextNumber]!=1){isOpen[NextNumber]=0};extend();>";
    msg[line] = "Title4"; 
    li2[line] = "</a></span></center><p></p><div class='box' id='box3'><div id='cont3'><p>测试..测试.</p><p>再次测试..</p><p>测试下拉效果</p></div></div>";
    linkurl[line] = "";text = msg[0].split("");  // Separate the line one sentence in each letter and write them into an 1D array
    function writetext(){  // This function will be rung when the whole page is loadedif(linefirst==1){
    text2 = text2+li1[count2];
    linefirst=0;
    }text1 =text2 + '<b style="color:#00FF00">'+text[count]+'</b>'; // Combine the dark and high-light letters together
    text2 = text2+text[count]; // Produce the dark letters
    //ps: A+=B is equal to A=A+B 
    fillHTML = eval(doc + '["nothing"]' + htm);  //ps: eval could be used as a function and it allows the strings writen inside run properly 
    // document["nothing"].document   OR   document.all["nothing"]
    if(is.ns4) {  // It will distinguish the IE version and use the most suitable method to print the textfillHTML.write(text1); fillHTML.close();
    } else { fillHTML.innerHTML = text1;} if (count < text.length -1){  // Check if the counting has reached the end of the linecount = count + 1;  // If not then count nextsetTimeout('writetext()',1)  // Make the Exploere wait for a millisecond and then run the writetext function again
    // ps: setTimeout is a method of Windows, and the unit is millisecond (1,000 millisecond = 1 second)} else{  // If it does reach the end of the linecount=0;  // Recover the quantity of countingtext2+=li2[count2]+'<p></p>'  // Add an new lineif (count2 < msg.length - 1){  // If the counting of the line hasn't reach the end of the paragraphcount2 = count2 + 1;  // Then count nexttext = eval('msg['+count2+'].split("")');  // Set the text of the next line
    linefirst=1;setTimeout('writetext()',1)  // Make the Exploere wait for a millisecond and then run the writetext function again}
    else{
    if(is.ns4) {  // It will distinguish the IE version and use the most suitable method to print the textfillHTML.write(text2); fillHTML.close();
    } else { fillHTML.innerHTML = text2;}
    } } } 
    function usefuction(useID){
    //parent.window.frames["Main"].deltext(useID);
    parent.window.frames["Main"].deltext(useID);
    }//===========Next will do the open boxes function===================
    var timer = 15;   //计时器时钟
    var MinHeght=0; //div最小高度,css中也要设置下这个值
    var aNum = 10;   //步进速度
    isOpen = new Array();//层状态 打开还是关闭 默认关闭
    var divname; //大Div标签的ID
    var subdivname; //小Div标签的ID
    var NextNumber; //记录点击文字的序号function $(id){return (document.getElementById) ? document.getElementById(id): document.all[id]}// 展开/关闭
    function extend(){
      var tHeight = parseInt(gs($(divname),"height"));
      var HeightEnd=$(subdivname).offsetHeight;//Div内实际高度
      //alert(tHeight);
      if(!(isOpen[NextNumber]==1)){
        $(divname).style.height=HeightEnd+"px";
          if (tHeight<HeightEnd){
          $(divname).style.height=(tHeight+aNum)+"px";
      //alert("a")
          setTimeout('extend('+divname+')',timer);
        }else{
          isOpen[NextNumber]=1; //打开状态
          //$(aid).innerHTML = "关闭";
        }
      }else{
        if((tHeight-aNum)>MinHeght){
          $(divname).style.height=(tHeight-aNum)+"px";
          setTimeout('extend('+divname+')',timer);
        }else{
          isOpen[NextNumber]=0; //关闭状态
          $(divname).style.height=MinHeght+"px";
          //$(aid).innerHTML = "展开";
        }
      }
    }function gs(d,a){
      if (d.currentStyle){ 
        var curVal=d.currentStyle[a];
      }else{ 
        var curVal=document.defaultView.getComputedStyle(d, null)[a];
      } 
      return curVal;
    }
    </SCRIPT>
    </p>
    <DIV id=nothing style="WIDTH: 30%; HEIGHT: 60%" align="right"></DIV>  
    </body>
    </html>但是测试后发现,这个合成物的初始状态并不是我理想中那样的,它在一开始就将所有的Div标签展开了,而且按下文字后也只是瞬间缩了一下,但是又变成了展开状态了……
    很头痛啊……
    请大家帮帮忙……
    我只是个学生,呵呵。。得向大师多多请教啊!~~