<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>我爱自己想</title>
<script type="text/javascript">
//效果:向左,向右滚动.
//setInterval事件.
var dir='left';
setInterval(function (){
if(dir==='left'){
//实现向左滚动
var firstDoc=document.title.charAt(0);
var others=document.title.substring(1,document.title.length);
document.title=others+firstDoc;
}else if(dir==='right'){
var lastDoc=document.title.charAt(document.title.length-1);
var others=document.title.substring(0,document.title.length-1);
document.title=lastDoc+others; }
},1000);
//为两个button注册单击事件
window.onload=function (){
//left:
document.getElementById('idLeft').onclick=function (){
dir='left';
}
//right;
document.getElementById('idright').onclick=function (){
dir='right';
}
}
</script>
</head>
<body>
<input type="button" name="name" value="left" id="idLeft" onclick="leftMoths()"></input>
<input type="button" name="name" value="right" id="idright" onclick="rightMoths()"></input>
</body>
</html>