一些關於網頁標題的動態js特效


1.當轉換頁面時,標題改變

<script>

document.addEventListener('visibilitychange',function(){

if(document.visibilityState=='hidden') {

normal_title=document.title;

document.title='(づ ̄ 3 ̄)づ';

}

else

document.title=normal_title;

});

</script>

2.標題閃動,你有新的消息

<script language="JavaScript">

 step=0

 function flash_title()

 {

  step++

  if (step==3) {step=1}         

  if (step==1) {document.title='【你有新的消息】'}

  if (step==2) {document.title='【      】'}

  setTimeout("flash_title()",380);

 }

 flash_title()

</script>

也可以嘗試瀏覽器兼容版

<script language="JavaScript"> 

setTimeout('flash_title()',2000); //2秒之后調用一次

function flash_title() 

  //當窗口效果為最小化,或者沒焦點狀態下才閃動

  if(isMinStatus() || !window.focus)

  {

    newMsgCount();

  }

  else

  {

    document.title='訂單管理中心-AOOXING';//窗口沒有消息的時候默認的title內容

    window.clearInterval();

  }

//消息提示

var flag=false;

function newMsgCount(){

  if(flag){

    flag=false;

    document.title='【新訂單】';

  }else{

    flag=true;

    document.title='【   】';

  }

  window.setTimeout('flash_title(0)',380); 

}

//判斷窗口是否最小化

//在Opera中還不能顯示

var isMin = false;

function isMinStatus() {

  //除了Internet Explorer瀏覽器,其他主流瀏覽器均支持Window outerHeight 和outerWidth 屬性

  if(window.outerWidth != undefined && window.outerHeight != undefined){

    isMin = window.outerWidth <= 160 && window.outerHeight <= 27;

  }else{

    isMin = window.outerWidth <= 160 && window.outerHeight <= 27;

  }

  //除了Internet Explorer瀏覽器,其他主流瀏覽器均支持Window screenY 和screenX 屬性

  if(window.screenY != undefined && window.screenX != undefined ){

    isMin = window.screenY < -30000 && window.screenX < -30000;//FF Chrome       

  }else{

    isMin = window.screenTop < -30000 && window.screenLeft < -30000;//IE

  }

  return isMin;

}

</script>

3.瀏覽器標題滾動跑馬燈

<!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>TITLE欄上滾動的文字</title>

<script language=javascript >

var text=document.title

var timerID

function newtext() {

clearTimeout(timerID)

document.title=text.substring(1,text.length)+text.substring(0,1)

text=document.title.substring(0,text.length)

timerID = setTimeout("newtext()", 100)

}

</script>

</head>

<body onload="newtext()"></body>

</body>

</html>

<html>

<head>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM