[code lang=”js”]
//now = new Date();
//dts = now.getSeconds();
//dtshow = Math.round(dts/2) //si she wuru;
dtshow = Math.floor(Math.random()*27);
switch(dtshow)
{
case 0:
document.write("<div class=right_bottom_box>Too many bots these days… Sign up here to prove that you’re a human!</div>")
break
case 1:
document.write("<div class=right_bottom_box>In Stoigmar, newsletter follow YOU!</div>")
break
case 2:
document.write("<div class=right_bottom_box>Adventurer’s wanted. High value investment! No questions asked!</div>")
break
case 3:
document.write("<div class=right_bottom_box>You can’t spell nexus without U! Sign up for our newsletter today!</div>")
break
case 4:
document.write("<div class=right_bottom_box>The oracle has said 110101111001010101.We’re still trying to find out what that means.</div>")
break
case 5:
document.write("<div class=right_bottom_box>Beta keys will be given to subscribers first!</div>")
break
case 6:
document.write("<div class=right_bottom_box>I’m following you, why won’t you follow me?</div>")
break
case 7:
document.write("<div class=right_bottom_box>Do elves actually wear pants? Sign up to find out!</div>")
break
case 8:
document.write("<div class=right_bottom_box>Get geared up for news about City of Steam! That’s what I’m torquing about!</div>")
break
case 9:
document.write("<div class=right_bottom_box>Sign up for our newsletter to make sure you’ll never run out of Steam!</div>")
break
case 10:
document.write("<div class=right_bottom_box>Mmm, Clocks… Mmm, Steam… Mmm, Newsletter…</div>")
break
case 11:
document.write("<div class=right_bottom_box>Just yank my lever, baby! (Sign up for our newsletter!)</div>")
break
case 12:
document.write("<div class=right_bottom_box>Find out what makes us tick! Sign up!</div>")
break
case 13:
document.write("<div class=right_bottom_box>I’d bet my last cog that you’ll find something to like in our newsletter!</div>")
break
case 14:
document.write("<div class=right_bottom_box>Did I mention exclusive Alpha Sneak Peek keys yet?</div>")
break
case 15:
document.write("<div class=right_bottom_box>I’m eyeing you buddy.</div>")
break
case 16:
document.write("<div class=right_bottom_box>Please give me your biometrics… Please?</div>")
break
case 17:
document.write("<div class=right_bottom_box>You’d think I was actually steampowered with all this smoke about…</div>")
break
case 18:
document.write("<div class=right_bottom_box>Join the Steam Team! Sign up today?</div>")
break
case 19:
document.write("<div class=right_bottom_box>The power of phlogiston compels you…to sign up for our newsletter.</div>")
break
case 20:
document.write("<div class=right_bottom_box>Don’t Myth a thing! Sign up for the City of Steam newsletter!</div>")
break
case 21:
document.write("<div class=right_bottom_box>Uncle robot wants YOU! to sign up for this newsletter.</div>")
break
case 22:
document.write("<div class=right_bottom_box>—(OnO)—Get these goggles for free if you sign up!</div>")
break
case 23:
document.write("<div class=right_bottom_box>Everybody else is doing it… shouldn’t you? … Please?</div>")
break
case 24:
document.write("<div class=right_bottom_box>Don’t not sign up for our newsletter. The steamtoilers need you. They look up to you.</div>")
break
case 25:
document.write("<div class=right_bottom_box>A newsletter a day keeps the ratlings away.</div>")
break
default:
document.write("<div class=right_bottom_box>I may not be a Panda, but please sign up for our Newsletter!</div>")
}
[/code]
首先看注释掉那部分
刚开始的时候不知道js随机数round的用法
于是我就获取时间,获取秒数,除于2
主要是我需要变换的文本大概有30个。
60秒/2的话有很多是小数点.5的。当时不知道js四舍五入
于是傻傻的出现很多default的内容。
后来我加了Math.round(dts/2)四舍五入。就好一些
我翻了一下js教程
看到了Math.floor(Math.random()*27)
随机产生数字。后面的数字27代表
随机产生0-26的数字。
于是我需要的效果就出来了。