闲着没事浏览网站的时候发现的这几段 JS 代码,记录下来并应用到了自己博客上。有喜欢这个小特效的朋友也可以直接拿过来使用,废话不多说,直接上代码。
网站标题自定义并滚动
// JS代码实现网站标题自定义 <script type="text/javascript"> var sTitle = "欢迎光临!蝈蝈要安静 | 一个不学无术的伪程序员" function TitleMove(){ sTitle = sTitle.substring(1, sTitle.length) + sTitle.substring(0, 1); document.title = sTitle; status = sTitle; } window.setInterval("TitleMove()", 100); </script>
网站标题滚动显示
// JS代码实现网站标题滚动显示 <script type="text/javascript"> var msg = document.title; msg = "………" + msg;pos = 0; function scrollMSG() { document.title = msg.substring(pos, msg.length) + msg.substring(pos, 0); pos++; if (pos > msg.length) pos = 0 window.setTimeout("scrollMSG()",200); } scrollMSG(); </script>
网站标题闪烁显示
// JS代码实现网站标题闪烁显示 <script type="text/javascript"> var step=0; var ftitle=document.title; //获取网页标题 var space=''; for(var i=0;i<=ftitle.length;i++)space+=' '; //根据标题长度生产相应的空字符 function flash_title(){ step++ if (step==3) {step=1} if (step==1) {document.title=space} if (step==2) {document.title=ftitle} setTimeout("flash_title()",500); } flash_title(); </script>
评论 (3)
This is a good tip particularly to those fresh to the
blogosphere. Brief but very accurate information…
Thank you for sharing this one. A must read post!
这些功能都挺实用了,不错
嗯嗯,毕竟终究要学以致用吗。哈哈