使用javascript定时器定时调用一个function,不能用SetTimer,要使用setInterval

     < html >
    
< head >
    
< script language = " javascript " >
    
var  timerHandle;
    
//  invoke alertalertalert every 1 seconds
    timerHandle  =  setInterval( " alertalertalert() " 1000 );

    
function  alertalertalert() {
        document.getElementById(
" tthandle " ).value  =  document.getElementById( " tthandle " ).value  +   " Hello here. "   +   " \n " ;
    }

    
function  releaseTimer() {
        clearInterval(timerHandle);
    }
    
< / script>   
     < body onunload = " releaseTimer() " >
    
< textarea cols = " 100 "  rows = " 10 "  readonly id = " tthandle " >< / textarea>
     < / body>
     < / html>

你可能感兴趣的:(SetInterval)