Using javascript to do a random call

  • 2020-03-30 01:41:59
  • OfStack

 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<title> Call the roll </title> 
<script language="javascript" type="text/javascript"> 
var status = 1; 
var name = new Array(' van   peng ',' Zhang Zihan ',' Generation of dawn ',' Sun.   season ',' Sun.   lei ',' Wang Honggang ',' Zeng Fanding ',' li   huan ',' zhu   ying ',' The king   Sally ',' Lin-lin zheng ',' Zhen-jia zhu ',' gold   one ',' Mr Lee ',' if   super ',' wu   tung ',' beam   good ',' liu   jung '); 

function getname(){ 
return name[Math.floor(Math.random()*name.length)]; 
} 
function showname(){ 
document.getElementById("name").innerHTML = getname(); 
setTimeout("showname",200); 
} 
function goname(){ 
intimer = setInterval(showname, 200); 
} 
function stopname(){ 
if(status == 1){ 
clearInterval(intimer); 
status = 0; 
}else{ 
intimer = setInterval(showname, 200); 
status = 1; 
} 
} 
</script> 
<style> 
#name{ 
border:1px solid #000; 
margin:auto; 
font-size:36px; 
color:#000000; 
width:108px; 
height:1em; 
cursor:pointer; 
text-align:center; 
} 
</style> 
</head> 
<body onLoad="goname()"> 
<div id="name" onClick="stopname()"></div> 
</body> 
</html> 

Related articles: