因為document.write是在另一版html write 一些文字出來
作用跟servlet的response.write一樣
你可以看看你write 出來的那個html的原碼,就會發現desliza這個function 不見了,因為找不到這個function,所以就會出現object expected這個訊息了
解決方法︰在同一版write
<body onload="addtext()">
<div id=test></div>
</body><script>
var timer=0;
function addtext(){
//document.write("test"+timer);
document.all.test.innerHTML+="test"+timer;
timer+=1;
if (timer<10)
setTimeout("addtext()",100)
}
</script>
你可以試試去掉那個comment

解决方案 »

  1.   

    给你一个:<html> 
    <head> 
    <title></title> 
    <script language="JavaScript"> 
    var msg="欢迎光临" 
    var delay=200 
    function scrollStatus() { 
    window.status=msg 
    msg=msg.substring(1,msg.length)+msg.substring(0,1) 
    timeID=setTimeout("scrollStatus()",delay) } 
    </script> 
    </head> 
    <body onload="scrollStatus()"> </body> 
    </html>
      

  2.   


    给你一个:<html> 
    <head> 
    <title></title> 
    <script language="JavaScript"> 
    var msg=">>> 欢 >>> 迎 >>> 光 >>> 临" 
    var delay=200 
    function scrollStatus() { 
    window.status=msg 
    msg=msg.substring(1,msg.length)+msg.substring(0,1) 
    timeID=setTimeout("scrollStatus()",delay) } 
    </script> 
    </head> 
    <body onload="scrollStatus()"> </body> 
    </html>
      

  3.   

    给一个标题栏跑信息的。<html> 
    <head> 
    <title></title> 
    <script language="JavaScript"> 
    var msg=">>> 欢 >>> 迎 >>> 光 >>> 临" 
    var delay=200 
    function scrollTitle() { 
    window.document.title=msg 
    msg=msg.substring(1,msg.length)+msg.substring(0,1) 
    timeID=setTimeout("scrollTitle()",delay) } 
    </script> 
    </head> 
    <body onload="scrollTitle()"> </body> 
    </html>
      

  4.   

    多谢各位大侠指教!我刚刚开始学用javascript,对html也不熟,在网上找了一大堆资料,看得头昏昏的,也不见什么效果,但我觉得这两种语言又不是很难,我该如何在短期内上手呢?请各位多多指点。
      

  5.   

    沒有一開始就看網上那些甚難的js的…
    programming講的不是你會幾多種語言,而是你寫program的方法
    建議一開始學一些比較容易的js(我一開始學是如何控制div內的屬性,好像我上面寫的那個,因為容易而且實用),從而建立自己的興趣及想法,到有一個時候你會發現自己所知的不夠用的時候,你就可以多學幾個function
    畢竟programmer講的是經驗,沒有人學幾天就可以大聲說「我已經學會啦!」
      

  6.   

    <SCRIPT language=javascript>
    setTimeout("word()",1000);
    function word(){
    Phrase="=">>> 欢 >>> 迎 >>> 光 >>> 临"
    Balises=""
    Taille=40;
    Midx=100;
    Decal=0.5;
    Nb=Phrase.length;
    y=-10000;
    for (x=0;x<Nb;x++){
    Balises=Balises + '<DIV Id=L' + x + ' STYLE="width:3;font-family: Courier New;font-weight:bold;position:absolute;top:40;left:50;z-index:0">' + Phrase.charAt(x) + '</DIV>'
    }
    document.write (Balises);
    Time=window.setInterval("Alors()",10);
    Alpha=5;
    I_Alpha=0.05;function Alors(){
    Alpha=Alpha-I_Alpha;
    for (x=0;x<Nb;x++){
    Alpha1=Alpha+Decal*x;
    Cosine=Math.cos(Alpha1);
    Ob=document.all("L"+x);
    Ob.style.posLeft=Midx+100*Math.sin(Alpha1)+50;
    Ob.style.zIndex=20*Cosine;
    Ob.style.fontSize=Taille+25*Cosine;
    Ob.style.color="rgb("+ (27+Cosine*80+50) + ","+ (127+Cosine*80+50) + ",0)";
    }
    }
    }
    </SCRIPT> 
      

  7.   

    把setTimeout("word()",1000);
    去掉