[zz]javascript: Dynamically change a normal text statement on a html page

http://www.delphifaq.com/faq/javascript/f606.shtml

<script language="JavaScript">
<!--
var iTime=5;
function update() {
var txt = 'Will update progress ';
if (iTime>1) { txt = txt + 'in ' + iTime + ' seconds.'; }
else {
  if (iTime==1) { txt = txt + 'in one second.'; }
  else { txt = txt + 'now.'; }
}
document.getElementById("cnt").innerHTML = txt;
iTime=iTime-1;
if(iTime>=0) { ID=window.setTimeout("update();",1000); }
else { document.location.href="http://www.w3schools.com"; }
}
// -->

 

</script>
</head>
<body onload="update()">

<div name=cnt id=cnt>Will update progress in 5 seconds.</div>

posted @ 2010-06-30 20:55  bettermanlu  阅读(2302)  评论(0编辑  收藏  举报