Cet article décrit comment JS met en œuvre l'effet de la création de titres de page Web Flash lorsque les messages arrivent. Partagez-le pour votre référence, comme suit:
<html xmlns = "http://www.w3.org/1999/xhtml"> <head runat = "server"> <Title> Unt Title Page </Title> <Script> var g_blinkid = 0; var g_blinkswitch = 0; var g_blinkttle = document.Title; var g_onlineusher = "; null; var g_newmsg_sound = null; var g_app_num = 0; var g_appnum = 0; var g_bappmore = false; var g_inputtime = 0; fonction blinknewmsg () {document.title = g_blinkswitch% 2 == 0? "【】 -" + g_blinktitle: "【Nouvelles nouvelles】 -" + g_blinktitle; g_blinkswitch ++;} g_blinkid = setInterval (blinkNewmsg, 1000); fonction stopSblinkNewmsg () {if (g_blinkid) {clearInterval (g_blinkid); g_blinkid = 0; document.title = g_blinktitle; }} </ script> </ head> <body> <form id = "form1" runat = "server"> <div> <input id = "Button1" type = "Button" value = "bouton" onClick = "stopBlinkNewmsg ();" /> </div> </ form> </ body> </html>Reportez-vous à Kaixin.com's Head-26.js
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_inut) blinkNewmsg () {var now = new Date (); var maintenant = maintenant.getTime (); if (nowtime - g_inputtime> 5000) {document.title = g_blinkswitch% 2? "【】 -" + g_blinktitle: "【Nouvelles nouvelles】 -" + g_blinktitle; } g_blinkswitch ++;} fonction blinkonline () {document.title = g_blinkswitch% 2? "○" + g_onlineUser + "est en ligne-" + g_blinktitle: "●" + g_onlineUser + "est en ligne-" + g_blinktitle; g_blinkswitch ++; if (g_blinkswitch> 10) {stopBlinkNewmsg (); }} Fonction CheckNewmsG () {var url = "/home/newmsg.php"; var pars = ""; var myajax = new ajax.request (url, {méthode: "post", paramètres: pars, onComplete: function (req) {checkNewmsgshow (req);}});} function stopBlinkNewmsg () {if (g_blinkid) {clairementInterval (g_blinkId); g_blinkid = 0; $ ("head_msgdiv"). style.display = "aucun"; document.title = g_blinktitle; }} var g_oldmsg = g_oldsysmsg = g_oldbbs = g_oldbbsReply = g_oldcomment = g_oldReply = 0; fonction CheckNewmsGshow (req) {var r = req.ResponSeText; stopBlinkNewmsg (); setTimeout (CheckNewmsG, 60000); eval ("r =" + r); var a_msglist = new Array ("msg", "sysmsg", "bbsreply", "comment", "réponse"); 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"). eval ("g_old" + a_msglist [i] + "= c;"); }} var newmsg = parseInt (r.msg) + parseInt (r.bbs) + parseInt (r.bbsReply) + parseInt (r.comment) + parseInt (r.reply); 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 ++) {evaled ("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 ("PermetcriptAccess", "Always"); g_newmsg_sound.addparam ("wMode", "opaque"); g_newmsg_sound.addparam ("menu", "false"); g_newmsg_sound.addvariable ("automatique", "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", "" 8 "#ffffff", true); g_sysmsg_sound.addparam ("permettre le driptaccess", "toujours"); g_sysmsg_sound.addparam ("wMode", "opaque"); g_sysmsg_sound.addparam ("menu", "false"); g_sysmsg_sound.addvariable ("automatique", "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); } pour (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 = "0 nouveaux éléments"; }} 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 (); }; }}}} fonction outputhead () {var v_html = '<div id = "head">' + '<div>' + '<div style = "margin-top: 3px;">' + '<div style = "padding-left: 18px;"> <a href = "/"> <img src = "http://img.kaixin001.com.cn/i2/kaixinlogo.gif" /> </a> </ div> '+' <div> '+' <div id = "hn1"> '+' <div> <a href = "/ home /? t = '+ math.ceil (math.random () * 100) + '"> Accueil </a> </ div>' + '<div> <a href =" javascript: xs (1); "> <img src =" http://img.kaixin001.com.cn/i/r_sj.gif "/> </a> </v>' + '<v> </v>' + '<div id =" hn1_ " <div> <a href = "/ home /"> ma page d'accueil </a> </ div> '+' <div> <a href = "/ home /"> ma page d'accueil </a> </ div> '+' <v> ma page d'accueil préviewale: </div> '+' <div> '+' <a href = "/ home /? _ prenew = ami" Target = _blank = onclick="javascript:hy();">'+' <div> style="margin:5px 3px;"><img src="http://img.kaixin001.com.cn/i/small-tri.gif" /></div>'+' <div style="cursor:pointer;">When friends visit</div>'+' <div> </ div> '+' </a> '+' </ div> '+' <div> '+' <a href = "/ home /? _ aperçu = autre" cible = _blank onclick = "javascript: hy ();" > '+' <div style = "margin: 5px 3px;"> <img src = "http://img.kaixin001.com.cn/i/small-tri.gif" /> </v> '+' <div style = "Cursor: pointer;"> quand un stangeur se rend </v> '+' <v> </v> '+' + '+' + '+' + '<v> </v>' + '+' + '+' + '+' + '<v> </v>' + '+' + '+' + '+' + '<v> </v>' + '+' + '+' + '+' + '<v> </v>' + '+' + '+' + '+' + '<Div> </ Div>' + '+' + '+' + '+' + '<v> </v>' + '+' + '+' + '+' + '+' <V> </ div> '+' </ div> '+' </ div> '+' <div id = "hn_xx1"> <img src = "http://img.kaixin001.com.cn/i/r_xx13.gif" /> </ div> '+' '+' <div id = "hn2"> '+' <div> <a hre = " Math.Ceil (Math.Random () * 100) + '"> Friends </a> </div>' + '<div> <a href =" javascript: xs (2); "> <img src =" http://img.kaixin001.com.cn/i/r_sj.gif "/> </a> <! - '+' <iframe style = "position: absolue; z-index: 1; width: expression (this.nextsibling.offsetwidth); hauteur: expression (this.nextsibling.offsetheight); top: expression (this.nextsibling.offsettop); gauche: expression (this.nextsibling.offsetleft);" frameborder = "0"> / iframe> '+' -> '+' <div id = "hn2_l" style = "z-index: 2"> '+' <div> <a href = "/ ami /"> mes amis </a> </ div> '+' <div> <a href = "/ friend /? Viewtype = online"> en ligne actuels amis </a> href = "/ ami / groupe.php"> Gestion d'amis </a> </div> '+' <div> <a href = "/ home / fstatus.php"> Friend Status Update </a> </div> '+' <v> <a href = "ami / invite.php"> Invitez des amis à rejoindre </a> </v> '+' <adiv> <a href = "/ ami / search.php"> trouver des amis </a> </ div> '+' </ div> '+' <div> <a href = "/ ami / search.php"> trouver des amis </a> </ div> '+' </ div> '+' <div id = "hn_xx2"> <img src = "http://img.kaixin001.com.cn/i/r_xx13.gif" /> </ div> '+' '+' <div id = "hn3"> '+' <v> <a href = "/ groupe /? t = '+ math.ceil (math.random () * 100) +'"> groupe </a> href = "javascript: xs (3);"> <img src = "http://img.kaixin001.com.cn/i/r_sj.gif" /> </a> </v> '+' <v> </ div> '+' <div id = "hn3_l"> '+' <v> <a href = "/ group /" ma! Groupe </a> </ div> '+' <div> <a href = "/ group / flist.php"> amis </a> </ div> '+' <div> <a href = "/ groupe / new.php"> Créer un nouveau groupe </a> </div> '+' <v> <a href = "/ group / search.php"> Les groupes </a> <div id = "hn_xx3"> <img src = "http://img.kaixin001.com.cn/i/r_xx13.gif" /> </ div> '+' '+' <div id = "hn_xx3"> <img src = "http://img.kaixin001.com.cn/i/r_xxX13.gif" /> </ div> '+' '+' <div id = "hn4" style = "padding-right: 28px;"> '+' <div> <a href = "/ msg /? t = '+ math.ceil (math.random () * 100) +'"> message </a> </ div> '+' <v> <a href = "javascript: xs (4); src = "http://img.kaixin001.com.cn/i/r_sj.gif" /> </a> <span style = "position: absolu; top: 5px; gauche: 65px; affichage: aucun;" id = head_msgdiv> <a href = "/ msg /" style = "margin-top: -5px;"> <img src = "http://img.kaixin001.com.cn/i/ddtx.gif" onMouseOver = "Javascript: xs (4);" border = 0> </a> </span> </div> '+' <div> </div> '+' <div id = "hn4_l"> '+' <div> <a href = "/ msg / inbox.php? t = '+ math.ceil (math.random () * 100) +'"> Message court <spyle = "padding-left: 2px; couleur;" id = head_msg_num> </ span> </a> </div> '+' <div> <a href = "/ msg / sys.php? t = '+ math.ceil (math.random () * 100) +'" "Message système <span style =" padding-left: 2px; couleur: "id = head_sysmsg_num> <div> <a href = "/ comment /? t = '+ math.ceil (math.random () * 100) +'"> commentaire <span style = "padding-left: 2px; colore: red;" id = head_comment_num> </ span> </a> </ div> '+' <v> <a href = "/ comment 100) + '"> commentaire Répondre <span style =" Padding-left: 2px; couleur: rouge; "id = head_reply_num> </span> </a> </div>' + '<v> <a href =" / commentaire / uindex.php? T =' + math.ceil (math.random () * 100) + '"> Board de message Style = "Padding-Left: 2px; Color: Red;" id = head_bbs_num> </span> </a> </div> '+' <div> <a href = "/ comment / usend.php? T = '+ Math.Ceil (math.random () * 100) +'"> Laisser une réponse de mess id = head_bbsreply_num> </span> </a> </ div> '+' </div> '+' <div> <a href = "/ ami / invite.php"> invite </a> ┊ <a href = "/ se se search.php"> Recherchez quelqu'un </a> href = "/ set / privacy.php"> Privacy </a> ┊ <a href = "/ login / logout.php"> exit </a> </ div> '+' <div> </ div> '+' </div> '+' <Div> </div> '+' <Div> </v> '+' <div> </div> '+' <siv> ' <div> </ div> '+' <div> </ div> '+' <div> </ div> '+' <div> '+' <div> </ div> '+' <div> '+' <div> </ div> '+' <div> '+' <div> </div> '+' <div> '+' id = "App_friend_tip" Style = "Z-index: 20000; Position: Absolute; Background: #ffff; Border: 2px Solid # f7f7f7; largeur: 160px; hauteur: 250px; Affichage: Aucun;"> '+' </div> '; v_index_num) {if (-1 == v_link.indexof ("?") {v_link + = "? t =" + math.ceil (math.random () * 100); 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> <img src = "'+ v_icon +'" align = "ABSMIDDLE" /> <a href = "'+ v_link +'"> <b> '+ v_title +' </b> </ad + '</v>' + '</ div id = "APPRIQUE_ Style = "Display: Aucun; padding: 8px 3px; cursor: pointeur;" onclick = "javascrip src = "http://img.kaixin001.com.cn/i2/xiasanjiao.gif" align = "Absmiddle" /> </div> '+' <div> </v> '+' </v_Link, v_html; document.writeln (_outputApp (v_icon, v_link, v_title, v_aid, v_index_num));} fonction _setApplistHidDead () {if (g_app_num == - 1) return ''; return '<span id = applistmore style = "Affichage: Aucun">';} return '';} fonction setApplistHidDenHed () {document.writeln (_setApplistHidDenDhead ();} fonction _setApplistHidDentail () {if (g_app_num == - 1) revint ''; id = applistcroll style = "margin-top: -10px;"> <img src = "http://img.kaixin001.com.cn/i2/xiala.gif" align = "ABSMIDDE"> <a href = "javascrip: showAppmore ();" style = " '';} fonction setAppListHidDentALD () {document.writeln (_setAppListHidDentAL ());} fonction outputhead2 () {document.write ('<v> <img src = "http://img.kaixin001.com.cn/i/index_app.gif" id = "install_tips" style = "position: absolue; gauche: 110px; top: -7px; z-index: 99; affichage: aucun;"> <div style = "padding: 7px 15px 0 0;"> <img src = "http://img.kaixin001.com.cn/I2/Black_del.gif" style = "cure onclick = "h (/ 'install_tips /')" /> </ div> <p style = "padding: 0px 20px;"> Cliquez ici pour ajouter divers composants pratiques ou de jeu </iMg.aixin001.com.cn/i/index_app_addd1.gif " href = "/ app / list.php"> Ajouter le composant </a> </ div> </ div> <div style = "margin-top: -8px;"> <img src = "http://img.kaixin001.com.cn/i/index_app_set1.gif" /> <a href = "/ set / appan Paramètres </a> </ div> </ div> ');} fonction showAppmore () {if ($ ("applistmore"). Style.display == "None") {$ ("applistmore"). Style.display = "block"; src = "http://img.kaixin001.com.cn/i2/shouqi.gif" align = "ABSMIDDE"> <a href = "JavaScript: showAppmore ();" style = "ApplistMore: Aucun; $ ("applistcroll"). innerhtml = '<img src = "http://img.kaixin001.com.cn/i2/xiala.gif" align = "Absmiddle"> <a href = "javascript: showAppmore ();"; outputAppinfo () {if (g_allapp_num> g_prevapp_num) {var url = "/app/left.php"; }); }. _OutputApp (data [i] ["icon"], data [i] ["lien"], data [i] ["title"], data [i] ["aid"], data [i] ["index_num"]); Document.Writeln ('<div> </div>' + '</div>' + '<div id = "b">' + '<div> <a href = "/ s / about.html" cible = "_ Blank"> À propos de nous </a> <span> ┊ </ span> <a href = "/ s / contacter.html" Target = "_ Blank"> Contact " Informations </a> <span> ┊ </span> <a href = "/ t / feedback.html" Target = "_ Blank"> feedback </a> <span> ┊ </span> <a href = "/ s / help.html" Target = "_ Blank"> Aide Center </a> © 2009 kaixin001.com <a class = c6 href = http: //www.miibeian.gov.cn Target = _blank> beijing icp certificat n ° 080482 </a> </v> '+' </v> ');}Pour plus d'informations sur le contenu lié à JavaScript, veuillez consulter les sujets de ce site: "Résumé des compétences de l'opération AJAX en JavaScript", "Résumé des compétences JavaScript Switching Effects and Techniques", "Résumé des effets spéciaux de la recherche Javascrip Compétences d'algorithme "," Résumé des algorithmes et techniques de traverse JavaScript "et" Résumé de l'utilisation des opérations mathématiques JavaScript "
J'espère que cet article sera utile à la programmation JavaScript de tous.