復(fù)制代碼 代碼如下:
<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 += "【未完待續(xù)】";
}
}, 200);
},
stopReader : function (t) {
t.flag = true;
clearInterval(t.toId);
},
continueReader : function (t) {
if (t.flag)
t.startReader();
t.flag = false;
}
};
var content = "蒙古親王僧格林沁慓悍勇猛,他率領(lǐng)的軍隊(duì)向來(lái)號(hào)稱能征慣戰(zhàn),八旗兵、綠營(yíng)他都看不上眼,更何況那些臨時(shí)招募的練勇。可偏偏就是這些他眼中的烏合之眾,這些年來(lái)在江南戰(zhàn)果累累,最終攻下了江寧,奪得了對(duì)太平軍作戰(zhàn)的全勝。" +
"相反地,他的蒙古鐵騎在與捻軍的角逐中常常打敗仗,相形之下,昔日的聲威銳減。這個(gè)一代天驕的后裔,對(duì)曾氏兄弟和湘軍窩著一肚皮無(wú)名怒火。" +
"湘軍進(jìn)江寧后,打劫財(cái)富,屠城縱火,又放走幼天王,朝野謗讟?biāo)钠穑镒h沸騰,僧格林沁聽(tīng)了十分得意,趕緊打發(fā)富明阿以視察滿城為由,去江寧實(shí)地了解。誰(shuí)料曾國(guó)荃一嚇一賄征服了富明阿,江寧將軍回去后向僧格林沁作了假匯報(bào)。";
//頁(yè)面加載完成之后執(zhí)行。
window.onload = function () {
new Reader(content, "content", "btnStop", "btnContinue").startReader();
};
</script>
<body>
<div></div>
<div><input type='button' value='stop'/><input type='button' value='continue'/></div>
</body>
</html>
新聞熱點(diǎn)
疑難解答
圖片精選