Dom之走马灯
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>走马灯的程序</title>
<script type="text/javascript">
var intervalid_left,intervalid_right;
function scroll_left() {
scroll_stop();
intervalid_left = setInterval("scroll_left()", 1500);
var title = document.title;
var firstchar = title.charAt(0);
var leftstr = title.substring(1, title.length);
document.title = leftstr + firstchar;
}
function scroll_right() {
scroll_stop();
intervalid_right = setInterval("scroll_right()", 1500);
var title = document.title;
var lastchar = title.charAt(title.length - 1);
var leftstr = title.substring(0, title.length - 1);
document.title = lastchar + leftstr;
}
function scroll_stop() {
clearInterval(intervalid_left);
clearInterval(intervalid_right);
}
</script>
</head>
<body>
<input type="button" value="左滚动" onclick="scroll_left()" />
<input type="button" value="右滚动" onclick="scroll_right()" />
</body>
</html>