JS implementation of the message to let the page title flashing effect of the method _javascript skills

Source: Internet
Author: User
Tags setinterval

This article is an example of a JS implementation of the message to let the page title flashing effect of the method. Share to everyone for your reference, specific as follows:

  
 

Refer to the head-26.js of Kaixin

var g_blinkid = 0;
var g_blinkswitch = 0;
var g_blinktitle = Document.title;
var g_onlineuser = "";
var g_sysmsg_sound = null;
var g_newmsg_sound = null;
var g_app_num = 0;
var g_appnum = 0;
var g_bappmore = false;
var g_inputtime = 0;
  function blinknewmsg () {var now = new Date ();
  var nowtime = Now.gettime (); if (Nowtime-g_inputtime > 5000) {document.title = g_blinkswitch% 2?
  "" "-" + G_blinktitle: "" New Message "-" + g_blinktitle;
} g_blinkswitch++; function Blinkonline () {document.title = g_blinkswitch% 2?
  "0" + G_onlineuser + "on the line-" + G_blinktitle: "" + G_onlineuser + "online-" + g_blinktitle;
  g_blinkswitch++;
  if (G_blinkswitch >) {stopblinknewmsg ();
  } function Checknewmsg () {var url = '/home/newmsg.php ';
  var pars = "";  var myajax = new Ajax.request (URL, {method: "Post", Parameters:pars, Oncomplete:function (req) {checknewmsgshow (req);}
}); The function stopblinknewmsg () {if (g_blinkid) {clearinterval (G_blinKid);
    G_blinkid = 0;
    $ ("Head_msgdiv"). Style.display = "None";
  Document.title = G_blinktitle;
} var g_oldmsg = g_oldsysmsg = G_oldbbs = g_oldbbsreply = g_oldcomment = g_oldreply = 0;
  function Checknewmsgshow (req) {var r = Req.responsetext;
  Stopblinknewmsg ();
  SetTimeout (checknewmsg, 60000);
  Eval ("r=" +r);
  var a_msglist = new Array ("MSG", "Sysmsg", "BBS", "bbsreply", "comment", "reply");
    if (R.notice = = "1") {var forbidsound = parseint (R.forbidsound); if (!forbidsound) {for (i=0 i<a_msglist.length; i++) {if ($ ("Body_" + a_msglist[i] + "_num")
          {var c = parseint ($ ("Body_" + a_msglist[i] + "_num"). InnerHTML);
        Eval ("G_old" + a_msglist[i] + "=C;"); } var newmsg = parseint (r.msg) + parseint (R.bbs) + parseint (r.bbsreply) + parseint (r.comment) + parseint (R.R
      eply);
      var sysmsg = parseint (r.sysmsg); var newchange = (parseint (r.msg)-g_oldmsg) | | (Parseint (r.bbs)-G_oldbbs | | (parseint (r.bbsreply)-g_oldbbsreply) | | (parseint (r.comment)-g_oldcomment) | |
      (parseint (r.reply)-g_oldreply);
      var syschange = (parseint (r.sysmsg)-g_oldsysmsg); For (i=0 i<a_msglist.length; i++) {eval ("G_old + a_msglist[i] +" =parseint (r. "+ A_msglist[i] +"); ")
      ; } if (newmsg && newchange) {if (G_newmsg_sound = null) {G_newmsg_sound = New SWFObject ("http://img.kaixin001.com.cn/i2/newmsg_sound.1.0.swf", "newmsg_sound_swf", "1", "1", "8", "#ffffff",
          true);
          G_newmsg_sound.addparam ("allowScriptAccess", "always");
          G_newmsg_sound.addparam ("wmode", "opaque");
          G_newmsg_sound.addparam ("menu", "false");
        G_newmsg_sound.addvariable ("AutoPlay", "0");
      } g_newmsg_sound.write ("Head_msgsound_div"); else if (sysmsg && syschange) {if (G_sysmsg_sound = null) {G_Sysmsg_sound = new SWFObject ("http://img.kaixin001.com.cn/i2/sysmsg_sound.1.0.swf", "sysmsg_sound_swf", "1", "1", "8"
          , "#ffffff", true);
          G_sysmsg_sound.addparam ("allowScriptAccess", "always");
          G_sysmsg_sound.addparam ("wmode", "opaque");
          G_sysmsg_sound.addparam ("menu", "false");
        G_sysmsg_sound.addvariable ("AutoPlay", "0");
      } g_sysmsg_sound.write ("Head_msgsound_div");
    } $ ("Head_msgdiv"). Style.display = "block";
  G_blinkid = SetInterval (blinknewmsg, 1000);
    else if (0 && r.online.length) {g_blinkswitch = 0;
    G_onlineuser = R.online;
  G_blinkid = SetInterval (Blinkonline, 500); For (i=0 i<a_msglist.length; i++) {if (!parseint (r[a_msglist[i)]) {$ ("Head_" + a_msglist[i] + "
      _num "). InnerHTML =" ";
        if ($ ("Body_" + a_msglist[i] + "_num")) {$ ("Body_" + a_msglist[i] + "_num"). ClassName = "QL2"; $ ("Body_" + a_msglist[i] + "_num"). InnerHTML = "0Article new ";
      } else {$ ("Head_" + a_msglist[i] + "_num"). InnerHTML = "(" + r[a_msglist[i]] + ");
        if ($ ("Body_" + a_msglist[i] + "_num")) {$ ("Body_" + a_msglist[i] + "_num"). ClassName = "Cr";
      $ ("Body_" + a_msglist[i] + "_num"). InnerHTML = R[a_msglist[i]] + "new"; } if (a_msglist[i] = = "MSG") {if (' function ' = = typeof (Msg_view_checknewmsg)) {msg
        _view_checknewmsg ();
      }; }} function Outputhead () {var v_html = ' <div id= ' head ' > ' + ' <div ' HD ' > ' + ' class= cl ass= "H1 wl1" style= "MARGIN-TOP:3PX;" > ' + ' <div style= "padding-left:18px;" ><a href= "/" class= "CF" title= "Happy Net" ></a></div> ' + ' </div> ' + ' <div class=" H2 "> ' + ' <div id=" hn1 "class=" hn_of " ; ' + ' <div class= ' hn_tt ' ><a href= '/home/?t= ' + math.ceil (MATH.RAndom () * +) + ' "class=" n "> Home </a></div> ' + ' <div class=" HN_SJ "><a href=" Javascript:xs (1) "Class=" SJ "></a></div> ' + ' <div C Lass= "C" ></div> ' + ' <div id= "hn1_l" class= "hn_l" > ' + ' <div><a href= "/home/" class=  "Hnm" > My home </a></div> ' + ' <div class= ' l1_h ' > </div> ' + ' <div class= ' C9 M0_15 "> My homepage Preview:</div> ' + ' <div> ' + ' <a href="/home/?_preview=friend "class=" HNM "tar Get=_blank onclick= "Javascript:hy ();" > ' + ' <div class= "L" style= "margin:5px 3px;" ></div> ' + ' <div class= "L" style= " Cursor:pointer; " > Friends Visit </div> ' + ' <div class= "C" ></div> ' + ' </a> ' + ' </div> ' + ' <div class= ' MB10 "> ' + ' <a href="/home/?_preview=other "class=" hnm "Target=_blank onclick=" Javascript:hy (); "> ' + ' <div class= "L" style= "margin:5px 3px;" ></div> ' + ' <div class= "L" style= " Cursor:pointer; " > Stranger Visit </div> ' + ' <div class= ' C ' ></div> ' + ' </a> ' + ' </div&gt ; ' + ' </div> ' + ' </div> ' + ' <div id= ' hn_xx1 ' class= ' hn_xx ' ></div> ' + ' + ' <div id= "hn2" class= "hn_of" > ' + ' <div C lass= "Hn_tt" ><a href= "/friend/?t= ' + Math.ceil (math.random () *) + '" class= "n" > Friend </a></div> ' + "<div class=" HN_SJ "><a href=" Javascript:xs (2); "class=" SJ "></a></div> ' + ' <div class= "C" &GT;&LT;/DIV&Gt; ' + ' <!--' + ' <iframe style= ' position:absolute;z-index:1;width:expression (this.nextSibling.offsetWid th); height:expression (this.nextSibling.offsetHeight); top:expression (This.nextSibling.offsetTop); Left: Expression (this.nextSibling.offsetLeft); "frameborder=" 0 "></iframe> ' + '--> ' + ' <div id=" hn2 _l "class=" hn_l "style=" z-index:2 "> ' +" <div><a href= "/friend/" class= "HNM" > All my friends </a></d          Iv> ' + ' <div><a href= "/friend/?viewtype=online" class= "hnm" > Current online friends </a></div> ' + ' <div><a href= "/friend/group.php" class= "hnm" > Buddy admin </a></div> ' + ' <div><a href
= "/home/fstatus.php" class= "Hnm" > Buddy status update </a></div> ' + ' <div class= ' l1_h ' > </div> ' + ' <div><a href= '/friend/invite.php ' class= ' hnm ' > Invite friends to join </a></div> ' + ' <div&gt <a href= "/friend/search.php" class= "HNM" > Find Friends </a></div> ' + ' </div> ' + ' </div> ' + ' <div id= ' hn_xx2 ' class= ' hn_xx ' > </div> ' + ' "+ ' <div id=" hn3 "class=" hn_of "> ' + ' <div class=" Hn_tt "><a href="/group/?t= ' + Math.ceil (math.random () * +) + ' "class=" n "> Group < /a></div> ' + ' <div class= "HN_SJ" ><a href= "Javascript:xs (3);" class= "SJ" ></a></div> ' + ' <div class= ' C ' ></div> ' + '           ;d IV id= "hn3_l" class= "hn_l" > ' + ' <div><a href= "/group/" class= "HNM" > My group </a></div> ' + ' <div><a href= "/group/flist.php" class= "HNM" > Friends Group </a></div> ' + ' <div class= ' l
1_h "> </div> ' + ' <div><a href="/group/new.php "class=" HNM "> Create new Group </a></div> ' + ' <div>&Lt;a href= "/group/search.php" class= "HNM" > All group </a></div> ' + ' </div> ' + ' </div> ' + '    <div id= "hn_xx3" class= "hn_xx" ></div> ' +" ' + ' <div id= ' hn4 ' class= ' hn_of ' style= ' padding-right:28px; > ' + ' <div class= "Hn_tt" ><a href= "/msg/?t= ' + Math.ceil (math.random () *) + '" class= "n" > Message </a ></div> ' + ' <div class= ' hn_sj "><a href=" Javascript:xs (4); "class=" SJ "></a><span style=" position:absolute;top:5px; Left:65px;display:none; "Id=head_msgdiv><a href="/msg/"class=" n "style=" margin-top:-5px ";" ></a></span></div > ' + ' <div class= ' C ' ></div> ' + ' <div id= ' hn4_l ' class= ' hn_l ' > ' + ' <div>& Lt;a href= "/msg/inboX.php?t= ' + Math.ceil (math.random () *) + ' "class=" HNM "> Short message <span style=" padding-left:2px;color:red "Id=head_ Msg_num></span></a></div> ' + ' <div><a href= '/msg/sys.php?t= ' + Math.ceil (Math.rando M () * +] + ' "class=" HNM "" > System Message <span style= "padding-left:2px;color:red;" id=head_sysmsg_num></span> </a></div> ' + ' <div class= ' l1_h ' > </div> ' + ' <div><a href= '/commen T/?t= ' + Math.ceil (math.random () *) + ' "class=" hnm "> Comments <span style=" padding-left:2px;color:red "Id=head_ Comment_num></span></a></div> ' + ' <div><a href= '/comment/send.php?t= ' + Math.ceil (M Ath.random () * + ' "class=" hnm "> Comments reply <span style=" padding-left:2px;color:red "id=head_reply_num></ Span></a></div> ' + ' <div><a href= '/comment/uindex.php?t= ' + Math.ceil (Math.random () * 100 ) + ' "class=" HNM "> Message board <span style=" PaddinG-left:2px;color:red "id=head_bbs_num></span></a></div> ' + ' <div><a href="/comment /usend.php?t= ' + Math.ceil (math.random () *) + ' "class=" HNM "> Message reply <span style=" padding-left:2px;color:red; "id =head_bbsreply_num></span></a></div> ' + ' </div> ' + ' </div> ' + ' <div I D= "hn_xx4" class= "hn_xx" ></div> ' + ' + ' <div class= ' C ' ></div> ' + ' </div> ' + ' & Lt;div class= "H3" ><a href= "/friend/invite.php" class= "ce" > Invitation </a>┊<a href= "/friend/search.php" class= "Ce" > Find someone </a>┊<a href= "/set/account.php" class= "ce" > Account </a>┊<a href= "/set/privacy.php" class= "CE" > Privacy </a>┊<a href= "/login/logout.php" class= "ce" > Exit </a></div> ' + ' <div class= "C" ></div> ' + ' </div> ' + ' </div> ' + ' <div id= ' Head_msgsound_div "style=" left:0;top:0;position: absolute; " ></div> ' + ' <div id= ' main"> ' + ' <div class=" M1 Wl1 "> ' + ' <div class=" m1t "></div> ' + ' <div id=" App_friend_tip "style= "Z-index:20000;position:absolute;background: #fff; border:2px solid #F7F7F7; width:160px;height:250px;display:none;"
  > ' + ' </div> ';
Document.writeln (v_html);
  function _outputapp (V_icon, V_link, V_title, V_aid, V_index_num) {if ( -1 = V_link.indexof ("?"))
  {V_link + = "t=" + Math.ceil (math.random () * 100);
  else {V_link + = "&t=" + Math.ceil (math.random () * 100); } v_html = ' <div style= ' margin:12px 15px 12px 15px; "onmouseover=" javascript:if (\ ' + v_index_num + ' \ ' ==\ ' 1\ ') {$ (\) App_friend_ ' + v_aid + ' \ '). style.display=\ ' Block\ ';} Onmouseout= "javascript:$" (\ ' app_friend_ ' + v_aid + ' \ '). style.display=\ ' none\ ';  > ' + ' <div class= "L" > <a href=" ' + V_link + ' "class=" SL "title=" ' + V_title + ' "><b class=" F14 "> ' + v_title + ' </b></a></div> ' + ' <div class= "L" id= "App_friend_ ' + V_aid + '" style= "display:none;padding:8px 3px;cursor:p Ointer "onclick=" javascript:a_appfriend_show (' + v_aid + ', \ ' + v_link + ' \ ', \ ' + v_title + ' \ '); " > ' + ' <div class= "C" ></div> ' + ' </div> ';
return v_html;  function Outputapp (V_icon, V_link, V_title, V_aid, v_index_num) {Document.writeln _outputapp (V_icon, V_link, V_title,
V_aid, V_index_num));
  function _setapplisthiddenhead () {if (g_app_num==-1) return ";
  g_appnum++;
    if (g_appnum>g_app_num &&!g_bappmore) {G_bappmore = true;
  Return ' <span id=applistmore style= ' display:none ' > ';
} return ';  function Setapplisthiddenhead () {Document.writeln (_setapplisthiddenhead ());} function _setapplisthiddentail () {if
  (g_app_num==-1) return "; if (G_bappmore) {RETurn ' </span><div id=applistscroll class= "tar" style= "margin-top:-10px;" > <a href= "Javascript:showappmore ();" class=
  "Sl-gray" style= "Text-decoration:none" title= "List all my Components" > expand </a>  </div> ";
} return '; function Setapplisthiddentail () {Document.writeln (_setapplisthiddentail ());} function OutputHead2 () {Document.wri Te (' <div class= "TAC mb5" ></div> < Div style= "position:relative;" > <div class= "install_tips" id= "Install_tips" style= "Position:absolute"; left:110px; top:-7px; z-index:99; Display:none; " > <div class= "tar" style= "padding:7px 15px 0 0;" > </div> <p style= "padding:0px 20px;" > Click here to add a variety of utility or game components </p></div> <div class= "P5 m0_10 Tac" > <a href= "/app/list.php" class= "SL2" > Add Components </a></div> </div> <div class= "P5 m0_10 Tac" style= "MARGIN-TOP:-8PX;" > <a href= "/set/appman.php"
class= "SL2" > Component Settings </a></div></div> ');
    function Showappmore () {if ($ ("Applistmore"). style.display== "None" {$ ("Applistmore"). style.display= "Block"; $ ("Applistscroll"). InnerHTML = '  <a href= "Javas Cript:showappmore (); "class=" Sl-gray "style=" Text-decoration:none; "
  > Close Up </a>   ';
    } else {$ ("Applistmore"). style.display= "None"; $ ("Applistscroll"). InnerHTML = '  <a href= " Javascript:showappmore (); "class=" Sl-gray "style=" Text-decoration:none; " > Expand </a>   ';
    }} function Outputappinfo () {if (G_allapp_num > G_prevapp_num) {var url = '/app/left.php ';
    var pars = ""; var myajax = new Ajax.request (URL, {method: "Post", Parameters:pars, Oncomplete:function (req) {outputappinfoajaxshow (R) EQ);
  } });
  } function Outputappinfoajaxshow (req) {eval ("data=" +req.responsetext);
  var v_html = ';
    for (var i=0 i<data.length; i++) {v_html + = _setapplisthiddenhead ();
  V_html + + _outputapp (data[i]["icon"), data[i]["link"], data[i]["title"], data[i]["aid"], data[i]["Index_num");
  } v_html + = _setapplisthiddentail ();
$ ("Head_applist"). InnerHTML =v_html;   function Outputtail () {Document.writeln (' <div class= "C" ></div> ' + ' </div> ' + ' <div id= "B" > ' + ') <div class= "B1" ><a href= "/s/about.html" class= "C6" target= "_blank" > About Us </a><span>┊</ Span><a href= "/s/contact.html" class= "C6" target= "_blank" > Contact way </a><span>┊</span><a Href= "/t/feedBack.html "class=" C6 "target=" _blank "> Feedback </a><span>┊</span><a href="/s/help.html "class=" C6 "target=" _blank "> Help Center </a>©2009 kaixin001.com  <a class=c6 Target
=_blank> ICP Certificate No. No. 080482 </a> </div> ' + ' </div> ');

 }

More readers interested in JavaScript-related content can view this site: "JavaScript Ajax Operating Skills Summary", "JavaScript switching effects and techniques summary", "JavaScript Search Algorithm Skills summary", " JavaScript animation effects and tips Summary, "JavaScript Error and debugging skills Summary", "JavaScript data structure and algorithm skills summary", "JavaScript traversal algorithm and Skills summary" and "JavaScript Mathematical operation Usage Summary"

I hope this article will help you with JavaScript programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.