A random name naming program made using javascript
This article mainly introduces a random name naming program using javascript. After testing, the results are quite good. For more information, see
The Code is as follows:
<! 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> name </title>
<Script language = "javascript" type = "text/javascript">
Var status = 1;
Var name = new Array ('fan Peng ', 'zhang zihan', 'dai tianming ', 'Sun Ji', 'Sun Lei ', 'wang Hongyu ', 'zeng fanding', 'Li Huan ', 'zhu ying', 'wang Sha', 'zheng Linlin', 'zhu zhenjia ', 'jin yi', 'Li chenglong ', 'yu Chao ', 'wu Tong', 'liang Liang ', 'Liu jun ');
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: pixel PX;
Height: 1em;
Cursor: pointer;
Text-align: center;
}
</Style>
</Head>
<Body onLoad = "goname ()">
<Div id = "name" onClick = "stopname ()"> </div>
</Body>
</Html>