请问如何把Remainder.html里的代码放在test.js文件里的,当运行a.html时,就调用test.js把内容都显示出来,就是如何把script放在js文件里运行。这是a.html里的代码
    <SCRIPT language=javascript src="test.js"></SCRIPT> 这里test.js里的代码
    document.write ("<table border='1px'>")
    document.write("<td align='center'>你的OP剩余时间</td></tr>")
    document.write("<td align='center'>Remainder.htm里的内容</td></tr>")
    document.write("</table>")这里是Remainder.html里的代码
    <span id="span_dt_dt" style='border:1px solid black;background-color:#FFFFFF' ></span>
    <SCRIPT language=javascript>
    function show_student163_time(){
        window.setTimeout("show_student163_time()", 1000);
        BirthDay=new Date("04-01-2012");//改成你的计时日期
        today=new Date();
        timeold=(BirthDay.getTime()-today.getTime());
        sectimeold=timeold/1000
        secondsold=Math.floor(sectimeold);
        msPerDay=24*60*60*1000
        e_daysold=timeold/msPerDay
        daysold=Math.floor(e_daysold);
        e_hrsold=(e_daysold-daysold)*24;
        hrsold=Math.floor(e_hrsold);
        e_minsold=(e_hrsold-hrsold)*60;
        minsold=Math.floor((e_hrsold-hrsold)*60);
        seconds=Math.floor((e_minsold-minsold)*60);
        span_dt_dt.innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ;
    }
    show_student163_time();
    </SCRIPT>

解决方案 »

  1.   

    把你的JS代码复制到JS文件里
    function show_student163_time(){ 
            window.setTimeout("show_student163_time()", 1000); 
            BirthDay=new Date("04-01-2012");//改成你的计时日期 
            today=new Date(); 
            timeold=(BirthDay.getTime()-today.getTime()); 
            sectimeold=timeold/1000 
            secondsold=Math.floor(sectimeold); 
            msPerDay=24*60*60*1000 
            e_daysold=timeold/msPerDay 
            daysold=Math.floor(e_daysold); 
            e_hrsold=(e_daysold-daysold)*24; 
            hrsold=Math.floor(e_hrsold); 
            e_minsold=(e_hrsold-hrsold)*60; 
            minsold=Math.floor((e_hrsold-hrsold)*60); 
            seconds=Math.floor((e_minsold-minsold)*60); 
            span_dt_dt.innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ; 
        } 然后在a.html的<body>标签中加入如下:
    <body onload='show_student163_time();'>如果你的js文件中有window.onload的话 就要换其他方式了
      

  2.   

    能不能具体点怎么做,function show_student163_time(){ 
            window.setTimeout("show_student163_time()", 1000); 
            BirthDay=new Date("04-01-2012");//改成你的计时日期 
            today=new Date(); 
            timeold=(BirthDay.getTime()-today.getTime()); 
            sectimeold=timeold/1000 
            secondsold=Math.floor(sectimeold); 
            msPerDay=24*60*60*1000 
            e_daysold=timeold/msPerDay 
            daysold=Math.floor(e_daysold); 
            e_hrsold=(e_daysold-daysold)*24; 
            hrsold=Math.floor(e_hrsold); 
            e_minsold=(e_hrsold-hrsold)*60; 
            minsold=Math.floor((e_hrsold-hrsold)*60); 
            seconds=Math.floor((e_minsold-minsold)*60); 
            span_dt_dt.innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ; 
        } 
    这些代码应该放到test.js文件里的哪个位置?