A javascript program for simulating novel reading

Source: Internet
Author: User

Copy codeThe Code is as follows:
<Html>
<Meta http-equiv = "content-type" content = "text/html; charset = UTF-8"/>
<Head>
<Title> </title>
<Script type = "text/javascript">
Function Reader (content, cID, stopID, continueID ){
This. conLoad = document. getElementById (cID );
This. stopBtn = document. getElementById (stopID );
This. continueBtn = document. getElementById (continueID );
This. content = content;
This. index = 0;
Var t = this;
This. stopBtn. onclick = (
Function (){
Return function (){
T. stopReader (t );
};
}) (T );
This. continueBtn. onclick = (
Function (){
Return function (){
T. continueReader (t );
};
}) (T );
}
Reader. prototype = {
StartReader: function (){
Var t = this;
T. toId = setInterval (function (){
If (t. content [t. index]) {
T. conLoad. innerHTML + = t. content [t. index];
}
T. index ++;
If (t. content. length = t. index ){
ClearInterval (t. toId );
T. conLoad. innerHTML + = "[To be continued ]";
}
},200 );
},
StopReader: function (t ){
T. flag = true;
ClearInterval (t. toId );
},
ContinueReader: function (t ){
If (t. flag)
T. startReader ();
T. flag = false;
}
};
Var content = "the prince of Mongolia is brave and brave, and the army he leads has always been known to be used to the war. He cannot see the eight flag soldiers or the green camp, not to mention those who are temporarily recruited and trained. However, these are all in his eyes. Over the past few years, the south of the Yangtze River suffered a great deal of results, and finally attacked Jiangning, winning the victory of the Taiping Army. "+
"On the contrary, his Mongolia iron ride often loses in the battle with the army, and in the dark, his old voice decreases sharply. The descendant of the generation of tianyao, with an unsung anger at Zeng's brother and Hunan army. "+
"After the Hunan army entered Jiangning, it robbed the fortune, destroyed the city, set fire, and let the young king go. The manye moles the four, and the discussion boiled. The Monk greenqin was very proud to hear it. He quickly sent fuming A to inspect mancheng, go to Jiangning to learn more. Who expected Zeng guoyi to fear a bribe to conquer fuming? After General Jiangning went back, he reported false information to the monk greenqin. ";
// Execute after the page is loaded.
Window. onload = function (){
New Reader (content, "content", "btnStop", "btnContinue"). startReader ();
};
</Script>
<Body>
<Div id = 'content'> </div>
<Div id = 'operate'> <input type = 'twent' id = 'btnstop' value = 'stop'/> <input type = 'twent' id = 'btncontinue 'value = 'continue '/> </div>
</Body>

</Html>

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.