A random name naming program made using javascript

Source: Internet
Author: User

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>

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.