上课了:JS实现网页标题滚动及标题变换
js实现网页标题滚动(源码如下)<script type=text/javascript>
var msg = document.title;
msg = "…" + msg;pos = 0;
function scrollMSG() {
document.title = msg.substring(pos, msg.length) + msg.substring(0, pos);
pos++;
if (pos >msg.length) pos = 0
window.setTimeout("scrollMSG()",400);
}
scrollMSG();
</script>
js实现网页标题变动(源码如下)
<scripttype=text/javascript>
//
var step=0;
var _title=document.title; //获取网页标题
var space='';
for(var i=0;i<=_title.length;i++)space+=' '; //根据标题长度生产相应的空字符
function flash_title() //核心函数
{
step++
if (step==3) {step=1}
if (step==1) {document.title=space}
if (step==2) {document.title=_title}
setTimeout("flash_title()",500);
}
flash_title();
</script>
页:
[1]