打字效果的JS

打字效果的JS
 <input type="text" value="瑞纳" id="Search1_txt_SerchKey"  onblur="shownew(true)" onfocus="shownew(false)" onclick="shownew(false)" />

<!--网站公告:<a id="HotNews" href="" target="_blank"></a>-->
<script language="JavaScript" type="text/javascript">
<!--
var NewsTime = 5000; //每条新闻的停留时间
var TextTime = 150; //新闻标题文字出现等待时间,越小越快

var newsi = 0;
var txti = 0;
var txttimer;
var newstimer;

var newstitle = new Array(); //新闻标题
var newshref = new Array(); //新闻链接

newstitle[
0] = "奎宇工作室最新web应用";
newshref[
0] = "http://www.kuiyu.net";

newstitle[
1] = "奎宇浏览器";
newshref[
1] = "http://www.kuiyu.net";

newstitle[
2] = "市场竞争日趋激烈 本周6款新车即将上市";
newshref[
2] = "http://www.kuiyu.net";

newstitle[
3] = "汽车交强险对外开放 法规年内有望出台";
newshref[
3] = "http://www.kuiyu.net";

newstitle[
4] = "奎宇工作室专业web开发";
newshref[
4] = "http://www.kuiyu.net";

function shownew(run) {
if (run == false) {
document.getElementById(
"Search1_txt_SerchKey").value = "";//清空输入框
clearInterval(txttimer);
clearInterval(newstimer);
return;
}

var endstr = "_"
hwnewstr
= newstitle[newsi];
newslink
= newshref[newsi];
if (txti == (hwnewstr.length - 1)) { endstr = ""; }
if (txti >= hwnewstr.length) {
clearInterval(txttimer);
clearInterval(newstimer);
newsi
++;
if (newsi >= newstitle.length) {
newsi
= 0
}
newstimer
= setInterval("shownew('run')", NewsTime);
txti
= 0;

}
clearInterval(txttimer);
// document.getElementById("HotNews").href = newslink;
// document.getElementById("HotNews").innerHTML = hwnewstr.substring(0, txti + 1) + endstr;
document.getElementById("Search1_txt_SerchKey").value = hwnewstr.substring(0, txti + 1) + endstr;
txti
++;
txttimer
= setInterval("shownew('run')", TextTime);
}
shownew(
true);
//-->
</script>
posted @ 2012-02-21 10:55  奎宇工作室  阅读(191)  评论(0编辑  收藏  举报