ホームページのタイトルバーは走馬灯の効果を実現します.


<script type="text/javascript">
    var dir="left";
    function scroll(){
        var title = document.title;
        if (dir == "left") {
            var firstch = title.charAt(0);
            var leftstr = title.substring(1, title.length);
            document.title = leftstr + firstch;
        }
        else if (dir == "right") {
            var endch = title.charAt(title.length - 1);
            var rightstr = title.substring(0, title.length - 1);
            document.title = endch + rightstr;
        }
        else {
            alert("      !");
        }
    }
    var IntervalId;
    function setDir(d) {
        dir = d;
        IntervalId = setInterval("scroll()", 300);
        }
        function clearIntervalTest() {
            clearInterval(IntervalId);
            alert("        !");
        }
script>
head>
<body>
<input type="button" value="      " onclick="setDir('left');"/>
<input type="button" value="      " onclick="setDir('right');"/>
<input type="button" value="  " onclick="clearIntervalTest()"/>
body>