<!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> |
<meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" /> |
<title>js实现标题栏跑马灯效果</title> |
<script type= "text/javascript" src="http: //code.jquery.com/jquery-1.8.2.min.js |
"> |
</script> |
</head> |
<body> |
<script language= "javascript" type= "text/ecmascript" > |
//定义要显示的文字,注意最好是在文字的前后都加上空格,显示时比较美观 |
var str= " js实现标题栏跑马灯效果!!! " ; |
//一个函数,循环调用 |
function check(){ |
//取出要显示文字的第一个字符然后拼接到字符串的末尾 |
str=str.substr(1)+str.substr(0,1); |
//把拼接好的字符串显示到状态栏 |
window.status=str; |
//把拼接好的字符串显示到标题栏 |
document.title=str; |
//每隔半秒调用一次,可以更改数字使它更快或更慢 |
setTimeout( "check()" ,500); |
} |
check(); |
</script> |
</body> |
</html> |