标题走马灯

    JScript,setInterval()方法的小应用。

    代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>这是标题走马灯</title>
</head>
<body>
    <script type="text/javascript">
        //setInterval()方法可按照指定的周期(以毫秒计)来调用函数或计算表达式。直到 clearInterval() 被调用或窗口被关闭。
        setInterval(function(){
            var temp=document.title;//临时变量得到标题
            var first=temp.charAt(0);//获取第一个标题第一个字
            document.title=temp.substring(1,temp.length)+first;//重新设置标题
        }
    ,500)
    </script>
</body>
</html>

 

posted @ 2012-10-14 19:51  阿朱姐姐  阅读(308)  评论(0编辑  收藏  举报

友情链接:@开源中国

回到顶部