查看完整版本: 打字效果的新闻标题

tension 2008-4-2 08:04

打字效果的新闻标题

[html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>打字效果的新闻标题</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
body{font-size:14px;font-weight:bold;}
</style>
</head>
<body>
最新内容:<a id="HotNews" href="" target="_blank"></a>
<SCRIPT LANGUAGE="JavaScript">
<!--
var NewsTime = 2000;        //每条新闻的停留时间
var TextTime = 50;                //新闻标题文字出现等待时间,越小越快

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

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

newstitle[0] = "23条科学设计你网站的方法";
newshref[0] = "http://bbs.pickbar.com/thread-1157-1-1.html";

newstitle[1] = "网页布局设计的标准尺寸";
newshref[1] = "http://bbs.pickbar.com/thread-1140-1-1.html";

newstitle[2] = "世界上最长的网页与最宽的网页";
newshref[2] = "http://bbs.pickbar.com/thread-912-1-1.html";

newstitle[3] = "2007流行网站导航设计欣赏";
newshref[3] = "http://bbs.pickbar.com/thread-1063-1-1.html";

newstitle[4] = "Soul 近期新作品";
newshref[4] = "http://bbs.pickbar.com/thread-1068-1-1.html";

function shownew()
{
        //code by haiwa @2005-10-21 [url]www.51windows.net[/url]
        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()",NewsTime);
                txti = 0;
                return;
        }
        clearInterval(txttimer);
        document.getElementById("HotNews").href=newslink;
        document.getElementById("HotNews").innerHTML = hwnewstr.substring(0,txti+1)+endstr;
        txti++;
        txttimer = setInterval("shownew()",TextTime);
}
shownew();
//-->
</SCRIPT>
</body>
</html>[/html]
页: [1]
查看完整版本: 打字效果的新闻标题