javascript實現(xiàn)的網頁標題變換效果(網頁游戲廣告常用)
更新時間:2011年01月02日 13:08:39 作者:
很多游戲廣告的推廣頁面中,為了吸引眼球,我們看到IE標題欄與狀態(tài)欄中都是來回閃動的效果。
核心代碼:
<SCRIPT type=text/javascript>
//
var step=0;
var _title=document.title; //獲取網頁標題
var space='';
for(var i=0;i<=_title.length;i++)space+=' '; //根據(jù)標題長度生產相應的空字符
function flash_title() //核心函數(shù)
{
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>
演示代碼:
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]
復制代碼 代碼如下:
<SCRIPT type=text/javascript>
//
var step=0;
var _title=document.title; //獲取網頁標題
var space='';
for(var i=0;i<=_title.length;i++)space+=' '; //根據(jù)標題長度生產相應的空字符
function flash_title() //核心函數(shù)
{
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>
演示代碼:
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]
相關文章
走馬燈效果代碼js appendChild實現(xiàn)的無縫滾動
走馬燈效果代碼js appendChild實現(xiàn)的無縫滾動2010-03-03

