[Hỏi đáp] Giúp đỡ về code báo tin nhắn

  Bài viết hay nhất1
Hỏi: Đây là code mình đang dùng
Code:
<script type="text/javascript">
$(function(){
   $("#i_icon_mini_new_message").length && $("title").text("[" + $("#i_icon_mini_new_message").attr("title").match(/\d+/) + "] - " + $("title").text());
});
</script>
Mình muốn thêm vào Có tin nhắn với [số tin nhắn] Nhảy qua nhảy lại

Đáp: https://devs.forumvi.com/t346-hoi-dap-giup-do-ve-code-bao-tin-nhan?showpost=p2202
  Bài viết hay nhất2
Code:
<script type="text/javascript">
$(function(){
   $("#i_icon_mini_new_message").length && ($("title").text("Có " + $("#i_icon_mini_new_message").attr("title").match(/\d+/) + " tin nhắn mới"), $("link[rel='shortcut icon']").attr("href", "https://dl.dropboxusercontent.com/u/126946313/new-mail.ico"));
});
</script>
  Bài viết hay nhất3
bác có thể dùng cách hiển thị ảnh của thanh Nav menu và ẩn thanh nav menu đi để 1 mục tin nhắn thôi và dùng ảnh động cho vô chỗ tin nhắn
  Bài viết hay nhất4
Ý t là đòng
[1] - tên topic
Có tin nhắn
nhảy qua nhảy lên trên title
  Bài viết hay nhất5
Tui đoán là cậu muốn làm cho nó nổi bật, nhưng title chỉ có thể làm chạy qua lại chứ nhảy lên thế nào được?
Hơn nữa khi mở nhiều tab trình duyệt, thì chỉ còn thấy favicon, title động cũng chẳng để làm gì.
Vì thế mình mới làm đổi favicon báo tin mới.

Bổ sung thêm 2 cách, có hiển thị số tin nhắn ở favicon

Cách 2:
Code:
$(function () {
   if ($("#i_icon_mini_new_message").length) {
      var a = parseInt($("#i_icon_mini_new_message").attr("title").match(/\d+/), 10);
      document.title = "tin nhắn mới";
      9 < a && (a = "plus");
      $("link[rel='shortcut icon']").attr("href", "http://dl.dropboxusercontent.com/u/126946313/number" + a + ".ico")
   }
});

Cách 3:
Code:
/*!
  Tinycon - A small library for manipulating the Favicon
  Tom Moor, http://tommoor.com
  Copyright (c) 2012 Tom Moor
  @license MIT Licensed
  @version 0.6.3
*/
(function(){var Tinycon={};var currentFavicon=null;var originalFavicon=null;var faviconImage=null;var canvas=null;var options={};var r=window.devicePixelRatio||1;var size=16*r;var defaults={width:7,height:9,font:10*r+'px arial',colour:'#ffffff',background:'#F03D25',fallback:true,crossOrigin:true,abbreviate:true};var ua=(function(){var agent=navigator.userAgent.toLowerCase();return function(browser){return agent.indexOf(browser)!==-1}}());var browser={ie:ua('msie'),chrome:ua('chrome'),webkit:ua('chrome')||ua('safari'),safari:ua('safari')&&!ua('chrome'),mozilla:ua('mozilla')&&!ua('chrome')&&!ua('safari')};var getFaviconTag=function(){var links=document.getElementsByTagName('link');for(var i=0,len=links.length;i<len;i++){if((links[i].getAttribute('rel')||'').match(/\bicon\b/)){return links[i]}}return false};var removeFaviconTag=function(){var links=document.getElementsByTagName('link');var head=document.getElementsByTagName('head')[0];for(var i=0,len=links.length;i<len;i++){var exists=(typeof(links[i])!=='undefined');if(exists&&(links[i].getAttribute('rel')||'').match(/\bicon\b/)){head.removeChild(links[i])}}};var getCurrentFavicon=function(){if(!originalFavicon||!currentFavicon){var tag=getFaviconTag();originalFavicon=currentFavicon=tag?tag.getAttribute('href'):'/favicon.ico'}return currentFavicon};var getCanvas=function(){if(!canvas){canvas=document.createElement("canvas");canvas.width=size;canvas.height=size}return canvas};var setFaviconTag=function(url){removeFaviconTag();var link=document.createElement('link');link.type='image/png';link.rel='icon';link.href=url;document.getElementsByTagName('head')[0].appendChild(link)};var log=function(message){if(window.console)window.console.log(message)};var drawFavicon=function(label,colour){if(!getCanvas().getContext||browser.ie||browser.safari||options.fallback==='force'){return updateTitle(label)}var context=getCanvas().getContext("2d");var colour=colour||'#000000';var src=getCurrentFavicon();faviconImage=document.createElement('img');faviconImage.onload=function(){context.clearRect(0,0,size,size);context.drawImage(faviconImage,0,0,faviconImage.width,faviconImage.height,0,0,size,size);if((label+'').length>0)drawBubble(context,label,colour);refreshFavicon()};if(!src.match(/^data/)&&options.crossOrigin){faviconImage.crossOrigin='anonymous'}faviconImage.src=src};var updateTitle=function(label){if(options.fallback){var originalTitle=document.title;if(originalTitle[0]==='('){originalTitle=originalTitle.slice(originalTitle.indexOf(' '))}if((label+'').length>0){document.title='('+label+') '+originalTitle}else{document.title=originalTitle}}};var drawBubble=function(context,label,colour){if(typeof label=='number'&&label>99&&options.abbreviate){label=abbreviateNumber(label)}var len=(label+'').length-1;var width=options.width*r+(6*r*len),height=options.height*r;var top=size-height,left=size-width-r,bottom=16*r,right=16*r,radius=2*r;context.font=(browser.webkit?'bold ':'')+options.font;context.fillStyle=options.background;context.strokeStyle=options.background;context.lineWidth=r;context.beginPath();context.moveTo(left+radius,top);context.quadraticCurveTo(left,top,left,top+radius);context.lineTo(left,bottom-radius);context.quadraticCurveTo(left,bottom,left+radius,bottom);context.lineTo(right-radius,bottom);context.quadraticCurveTo(right,bottom,right,bottom-radius);context.lineTo(right,top+radius);context.quadraticCurveTo(right,top,right-radius,top);context.closePath();context.fill();context.beginPath();context.strokeStyle="rgba(0,0,0,0.3)";context.moveTo(left+radius/2.0,bottom);context.lineTo(right-radius/2.0,bottom);context.stroke();context.fillStyle=options.colour;context.textAlign="right";context.textBaseline="top";context.fillText(label,r===2?29:15,browser.mozilla?7*r:6*r)};var refreshFavicon=function(){if(!getCanvas().getContext)return;setFaviconTag(getCanvas().toDataURL())};var abbreviateNumber=function(label){var metricPrefixes=[['G',1000000000],['M',1000000],['k',1000]];for(var i=0;i<metricPrefixes.length;++i){if(label>=metricPrefixes[i][1]){label=round(label/metricPrefixes[i][1])+metricPrefixes[i][0];break}}return label};var round=function(value,precision){var number=new Number(value);return number.toFixed(precision)};Tinycon.setOptions=function(custom){options={};for(var key in defaults){options[key]=custom.hasOwnProperty(key)?custom[key]:defaults[key]}return this};Tinycon.setImage=function(url){currentFavicon=url;refreshFavicon();return this};Tinycon.setBubble=function(label,colour){label=label||'';drawFavicon(label,colour);return this};Tinycon.reset=function(){setFaviconTag(originalFavicon)};Tinycon.setOptions(defaults);window.Tinycon=Tinycon;if(typeof define==='function'&&define.amd){define(Tinycon)}})();
$(function(){if($("#i_icon_mini_new_message").length){var a=$("#i_icon_mini_new_message").attr("title").match(/\d+/);document.title="Có "+a+" tin nhắn mới";Tinycon.setBubble(a)}});
  Bài viết hay nhất6
:D tối ghi nhầm nhảy qua nhảy lại giống bên fb :D
  Bài viết hay nhất7
Thêm các code này ở đâu nhỉ?
  Bài viết hay nhất8
ko biết có hợp í anh ko, nhưng em thấy cái này cũng hay đó anh

Code:
/***
    * Application: Private Message list.
    * Description: This application can displays the list of PM in related menus.
    * Version: 1.03102014-jq1.9.1 - Hermes Kriophoros
    * Made and Optimizations by JScript - 2014/03/10
    * View more in: http://ajuda.forumeiros.com
    * Copyright (c) 2013 JScript <jscriptbrasil at live dot com>
    * This work is free. You can redistribute it and/or modify it
    * under the terms of the WTFPL, Version 2
    */
    jQuery(function () {
        /***
        * User Definition Variables
        ***/
        /* Put here the amount number of PMs returned!!! */
        var iAmount = 5; 
        /***
        * System Defined Variables - Do not edit if you don't know!
        ***/
        var oConfig = {
            sInfo:
                '<!--' +
                '* Application: Private Message List.' +
                '* Description: This application can displays the list of PM in related menus.' +
                '* Version: 1.03102014-jq1.9.1 - Hermes Kriophoros' +
                '* Made and Optimizations by JScript - 2014/03/10' +
                '* View more in: http://codeforum.besaba.com/forum/index.php' +
                '* Copyright (c) 2014 JScript <jscriptbrasil at live dot com>' +
                '* This work is free. You can redistribute it and/or modify it' +
                '* under the terms of the WTFPL, Version 2' +
                '-->',     
            sContent:
                '<div class="ipsHeaderMenu boxShadow" id="user_inbox_link_menucontent" style="display: none; width: 300px; position: absolute; z-index: 9999;">' +
                    '<h4 class="ipsType_sectiontitle">Inbox folder' +
                        '<p class="ipsPad_half ipsType_smaller right">' +
                            '<a class="configure" href="/privmsg?folder=inbox">Messages</a> · <a href="/privmsg?mode=post" title="New message">New message</a>' +
                        '</p>' +
                    '</h4>' +
                    '<ul class="ipsList_withminiphoto"><img src="http://i55.servimg.com/u/f55/18/17/62/92/ajax-l10.gif" alt="- Load" style="display: block; margin-left: auto; margin-right: auto;"></ul>' +
                '</div>',     
            sCSS:
                '<style>' +
                '.ipsHeaderMenu {' +
                    'background-color: #FFFFFF;' +
                    'border-radius: 0 0 6px 6px;' +
                    'overflow: hidden;' +
                    'padding: 10px;' +
                    'width: 340px;' +
                '}' +
                '.boxShadow {' +
                    'box-shadow: 0 12px 25px rgba(0, 0, 0, 0.58);' +
                '}' +
                '.ipsHeaderMenu .ipsType_sectiontitle {' +
                    'margin-bottom: 8px;' +
                '}' +
                '.ipsType_sectiontitle {' +
                    'border-bottom: 1px solid #ECECEC;' +
                    'color: #595959;' +
                    'font-size: 16px;' +
                    'font-weight: 400;' +
                    'padding: 5px 0;' +
                '}' +
                '.ipsType_smaller, .ipsType_smaller a {' +
                    'font-size: 11px !important;' +
                '}' +
                '.ipsPad_half {' +
                    'padding: 4px !important;' +
                '}' +
                '.right {' +
                    'float: right;' +
                '}' +
                '.ipsList_withminiphoto > li {' +
                    'margin-bottom: 8px;' +
                '}' +
                '.ipsType_small {' +
                    'font-size: 12px;' +
                '}' +
                '.ipsUserPhoto {' +
                    'background: none repeat scroll 0 0 #FFFFFF;' +
                    'border: 1px solid #D5D5D5 !important;' +
                    'box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);' +
                    'padding: 1px;' +
                '}' +
                '.ipsUserPhoto_mini {' +
                    'height: 30px;' +
                    'width: 30px;' +
                '}' +
                '.left {' +
                    'float: left;' +
                '}' +
                '.ipsList_withminiphoto > li .list_content {' +
                    'margin-left: 40px;' +
                '}' +
                '#user_inbox_link_menucontent ul.ipsList_withminiphoto {' +
                    'list-style: none outside none;' +
                    'padding-left: 0 !important;' +
                '}' +
                '.desc.lighter, .desc.lighter.blend_links a {' +
                    'color: #A4A4A4;' +
                '}' +
                '.ipsType_smaller, .ipsType_smaller a {' +
                    'font-size: 11px !important;' +
                '}' +
                '.menu_active {' +
                    'color: #595959 !important;' +
                    'background-color: #FFFFFF !important;' +
                    'background-position: center bottom;' +
                    'border-radius: 3px 3px 0 0;' +
                    'padding: 4px;' +
                '}' +
                '</style>',
            sTarget: '',
            sSearch: '',
            sExpression0: '',
            sExpression1: '',
            sExpression2: '',
            sGetIMG: ''
        };
        /* Add CSS */
        /*document.head.insertAdjacentHTML('beforeEnd', oConfig.sCSS);*/
        jQuery(oConfig.sCSS).insertBefore('body');
        jQuery('body').append(oConfig.sInfo + oConfig.sContent);
        /* Forum versions! */
        var phpBB2 = jQuery('.bodyline');
        var phpBB3 = jQuery('#wrap');
        var punbb = jQuery('#pun-intro');
        var invision = jQuery('#ipbwrapper');
     
        if (phpBB2.length) {
            oConfig.sSearch = 'form[name="privmsg_list"] .forumline tr';
            oConfig.sTarget = 'tr';
            oConfig.sExpression0 = 'memDiv.find("tr:first, tr:last").remove();';
            oConfig.sExpression1 = 'jQuery(this).find("a.topictitle").html()';
            oConfig.sExpression2 = 'jQuery(this).find("td .name").html() + " - " + jQuery(this).find("td .postdetails").html()';
            oConfig.sGetIMG = ' #emptyidcc .row1.gensmall img:eq(0)';
        } else if(phpBB3.length) {
            oConfig.sSearch = '.topiclist.pmlist.bg_none li';
            oConfig.sTarget = '.icon dt';
            oConfig.sExpression1 = 'jQuery(this).find("a.topictitle")[0].outerHTML';
            oConfig.sExpression2 = 'jQuery(this).find("em").html()';
            oConfig.sGetIMG = ' #profile-advanced-right img:eq(0)';
        } else if(punbb.length) {
            oConfig.sSearch = '.main-content tr .tcl.tdtopics';
            oConfig.sGetIMG = ' #profile-advanced-right .main-content img:first';
        } else if(invision.length) {
            oConfig.sSearch = '.borderwrap table.ipbtable tbody tr:not(":empty")';
            oConfig.sTarget = 'tr';
            oConfig.sExpression1 = 'var _tmp1 = jQuery(this).find("td:eq(2)");_tmp1.children("a.topictitle")[0].outerHTML';
            oConfig.sExpression2 = '_tmp1.children("a.topictitle").remove();_tmp1.html()';
            oConfig.sGetIMG = ' #profile-advanced-right .box-content.profile.center img:first';
        };
     
        jQuery('a[href*="/privmsg?folder=inbox"]').click(function () {
            var oClicked = jQuery(this);
            var oTarget = jQuery('#user_inbox_link_menucontent');
            if (oTarget[0].style.display == 'none') {
                oClicked.addClass('menu_active');
             
                if ( !jQuery('#user_inbox_link_menucontent ul.ipsList_withminiphoto > li').length ) {
                    var memDiv = jQuery('<div>');
                    memDiv.load('/privmsg?folder=inbox ' + oConfig.sSearch + ':lt(' + iAmount + ')', function() {
                        if (punbb.length) {
                            memDiv
                                .html(
                                    memDiv.html()
                                        .replace(/\<\/a\> por/g, '</a></br><span class="ipsType_smaller desc lighter">')
                                        .replace(/\<\/td\>/g, '</span></div></li>')
                                        .replace(/\<td class="tcl tdtopics"\>/g, '<li class="ipsType_small clearfix"><img class="ipsUserPhoto ipsUserPhoto_mini left" alt="User image" src="http://i78.servimg.com/u/f78/18/17/62/92/defaul10.png"><div class="list_content">')
                                )
                                .find('span.status').remove();
                        } else {
                            if (oConfig.sExpression0) {
                                eval( oConfig.sExpression0 );
                            }
                            var sHtml = '';
                            oConfig.sTarget = memDiv.find(oConfig.sTarget);
                            jQuery.each(oConfig.sTarget, function( index, value ) {
                                sHtml +=
                                    '<li class="ipsType_small clearfix">' +
                                        '<img class="ipsUserPhoto ipsUserPhoto_mini left" alt="User image" src="http://i78.servimg.com/u/f78/18/17/62/92/defaul10.png">' +
                                        '<div class="list_content">' +
                                            eval( oConfig.sExpression1 ) + '<br>' +
                                            '<span class="ipsType_smaller desc lighter">' + eval( oConfig.sExpression2 ) + '</span>' +
                                        '</div>' +
                                    '</li>';
                            });
                            memDiv.html(sHtml);
                        }
                        jQuery('#user_inbox_link_menucontent ul.ipsList_withminiphoto').html(memDiv.html());
                        var oImgTarget = oTarget.find('.ipsType_small.clearfix');
                        oImgTarget.each(function( index ) {
                            var UserURL = jQuery(this).find('.ipsType_smaller a, .list_content a:last');
                            if (UserURL.length) {
                                UserURL = UserURL.attr('href');
                                var oImgTag = jQuery(this).find('.ipsUserPhoto');
                                var UserIMG = sessionStorage.getItem(UserURL); /* Gets the avatar saved in local storage */
                                /* If avatar alread saved, then no request member profile! */
                                if(UserIMG) {
                                    jQuery(this).find('img').attr('src', UserIMG);
                                } else {
                                    /* if not, then only request per session!!! */
                                    jQuery.get(UserURL, function(data){
                                        var profile_img = jQuery(oConfig.sGetIMG, data).attr('src');
                                        if (profile_img !== undefined) {
                                            oImgTag.attr('src', profile_img);
                                            /* Saves the member avatar in local storage */
                                            sessionStorage.setItem(UserURL, profile_img);
                                        }
                                    });
                                }
                            }
                        });
                    });
                }
                oTarget
                    .css({
                        'left': (oClicked.offset().left + oClicked.outerWidth()) - oTarget.outerWidth(),
                        'top': oClicked.offset().top + oClicked.outerHeight()
                    })         
                    .fadeIn(400);
                jQuery(document).mousedown(function() {
                    if(!oTarget.is(":hover")) {
                        jQuery(document).unbind('mousedown');
                        oClicked.removeClass('menu_active');
                        oTarget.fadeOut(400);
                    }
                });         
            } else {
                oClicked.removeClass('menu_active');
                oTarget.fadeOut(400);
            }
            return false;
        });
    });

Demo:

[Hỏi đáp] Giúp đỡ về code báo tin nhắn P9iCIZx
  Bài viết hay nhất9

roseila wrote:ko biết có hợp í anh ko, nhưng em thấy cái này cũng hay đó anh

Code:
/***
     * Application: Private Message list.
     * Description: This application can displays the list of PM in related menus.
     * Version: 1.03102014-jq1.9.1 - Hermes Kriophoros
     * Made and Optimizations by JScript - 2014/03/10
     * View more in: http://ajuda.forumeiros.com
     * Copyright (c) 2013 JScript <jscriptbrasil at live dot com>
     * This work is free. You can redistribute it and/or modify it
     * under the terms of the WTFPL, Version 2
     */
    jQuery(function () {
        /***
        * User Definition Variables
        ***/
        /* Put here the amount number of PMs returned!!! */
        var iAmount = 5;  
        /***
        * System Defined Variables - Do not edit if you don't know!
        ***/
        var oConfig = {
            sInfo:
                '<!--' +
                '* Application: Private Message List.' +
                '* Description: This application can displays the list of PM in related menus.' +
                '* Version: 1.03102014-jq1.9.1 - Hermes Kriophoros' +
                '* Made and Optimizations by JScript - 2014/03/10' +
                '* View more in: http://codeforum.besaba.com/forum/index.php' +
                '* Copyright (c) 2014 JScript <jscriptbrasil at live dot com>' +
                '* This work is free. You can redistribute it and/or modify it' +
                '* under the terms of the WTFPL, Version 2' +
                '-->',      
            sContent:
                '<div class="ipsHeaderMenu boxShadow" id="user_inbox_link_menucontent" style="display: none; width: 300px; position: absolute; z-index: 9999;">' +
                    '<h4 class="ipsType_sectiontitle">Inbox folder' +
                        '<p class="ipsPad_half ipsType_smaller right">' +
                            '<a class="configure" href="/privmsg?folder=inbox">Messages</a> · <a href="/privmsg?mode=post" title="New message">New message</a>' +
                        '</p>' +
                    '</h4>' +
                    '<ul class="ipsList_withminiphoto"><img src="http://i55.servimg.com/u/f55/18/17/62/92/ajax-l10.gif" alt="- Load" style="display: block; margin-left: auto; margin-right: auto;"></ul>' +
                '</div>',      
            sCSS:
                '<style>' +
                '.ipsHeaderMenu {' +
                    'background-color: #FFFFFF;' +
                    'border-radius: 0 0 6px 6px;' +
                    'overflow: hidden;' +
                    'padding: 10px;' +
                    'width: 340px;' +
                '}' +
                '.boxShadow {' +
                    'box-shadow: 0 12px 25px rgba(0, 0, 0, 0.58);' +
                '}' +
                '.ipsHeaderMenu .ipsType_sectiontitle {' +
                    'margin-bottom: 8px;' +
                '}' +
                '.ipsType_sectiontitle {' +
                    'border-bottom: 1px solid #ECECEC;' +
                    'color: #595959;' +
                    'font-size: 16px;' +
                    'font-weight: 400;' +
                    'padding: 5px 0;' +
                '}' +
                '.ipsType_smaller, .ipsType_smaller a {' +
                    'font-size: 11px !important;' +
                '}' +
                '.ipsPad_half {' +
                    'padding: 4px !important;' +
                '}' +
                '.right {' +
                    'float: right;' +
                '}' +
                '.ipsList_withminiphoto > li {' +
                    'margin-bottom: 8px;' +
                '}' +
                '.ipsType_small {' +
                    'font-size: 12px;' +
                '}' +
                '.ipsUserPhoto {' +
                    'background: none repeat scroll 0 0 #FFFFFF;' +
                    'border: 1px solid #D5D5D5 !important;' +
                    'box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);' +
                    'padding: 1px;' +
                '}' +
                '.ipsUserPhoto_mini {' +
                    'height: 30px;' +
                    'width: 30px;' +
                '}' +
                '.left {' +
                    'float: left;' +
                '}' +
                '.ipsList_withminiphoto > li .list_content {' +
                    'margin-left: 40px;' +
                '}' +
                '#user_inbox_link_menucontent ul.ipsList_withminiphoto {' +
                    'list-style: none outside none;' +
                    'padding-left: 0 !important;' +
                '}' +
                '.desc.lighter, .desc.lighter.blend_links a {' +
                    'color: #A4A4A4;' +
                '}' +
                '.ipsType_smaller, .ipsType_smaller a {' +
                    'font-size: 11px !important;' +
                '}' +
                '.menu_active {' +
                    'color: #595959 !important;' +
                    'background-color: #FFFFFF !important;' +
                    'background-position: center bottom;' +
                    'border-radius: 3px 3px 0 0;' +
                    'padding: 4px;' +
                '}' +
                '</style>',
            sTarget: '',
            sSearch: '',
            sExpression0: '',
            sExpression1: '',
            sExpression2: '',
            sGetIMG: ''
        };
        /* Add CSS */
        /*document.head.insertAdjacentHTML('beforeEnd', oConfig.sCSS);*/
        jQuery(oConfig.sCSS).insertBefore('body');
        jQuery('body').append(oConfig.sInfo + oConfig.sContent);
        /* Forum versions! */
        var phpBB2 = jQuery('.bodyline');
        var phpBB3 = jQuery('#wrap');
        var punbb = jQuery('#pun-intro');
        var invision = jQuery('#ipbwrapper');
      
        if (phpBB2.length) {
            oConfig.sSearch = 'form[name="privmsg_list"] .forumline tr';
            oConfig.sTarget = 'tr';
            oConfig.sExpression0 = 'memDiv.find("tr:first, tr:last").remove();';
            oConfig.sExpression1 = 'jQuery(this).find("a.topictitle").html()';
            oConfig.sExpression2 = 'jQuery(this).find("td .name").html() + " - " + jQuery(this).find("td .postdetails").html()';
            oConfig.sGetIMG = ' #emptyidcc .row1.gensmall img:eq(0)';
        } else if(phpBB3.length) {
            oConfig.sSearch = '.topiclist.pmlist.bg_none li';
            oConfig.sTarget = '.icon dt';
            oConfig.sExpression1 = 'jQuery(this).find("a.topictitle")[0].outerHTML';
            oConfig.sExpression2 = 'jQuery(this).find("em").html()';
            oConfig.sGetIMG = ' #profile-advanced-right img:eq(0)';
        } else if(punbb.length) {
            oConfig.sSearch = '.main-content tr .tcl.tdtopics';
            oConfig.sGetIMG = ' #profile-advanced-right .main-content img:first';
        } else if(invision.length) {
            oConfig.sSearch = '.borderwrap table.ipbtable tbody tr:not(":empty")';
            oConfig.sTarget = 'tr';
            oConfig.sExpression1 = 'var _tmp1 = jQuery(this).find("td:eq(2)");_tmp1.children("a.topictitle")[0].outerHTML';
            oConfig.sExpression2 = '_tmp1.children("a.topictitle").remove();_tmp1.html()';
            oConfig.sGetIMG = ' #profile-advanced-right .box-content.profile.center img:first';
        };
      
        jQuery('a[href*="/privmsg?folder=inbox"]').click(function () {
            var oClicked = jQuery(this);
            var oTarget = jQuery('#user_inbox_link_menucontent');
            if (oTarget[0].style.display == 'none') {
                oClicked.addClass('menu_active');
              
                if ( !jQuery('#user_inbox_link_menucontent ul.ipsList_withminiphoto > li').length ) {
                    var memDiv = jQuery('<div>');
                    memDiv.load('/privmsg?folder=inbox ' + oConfig.sSearch + ':lt(' + iAmount + ')', function() {
                        if (punbb.length) {
                            memDiv
                                .html(
                                    memDiv.html()
                                        .replace(/\<\/a\> por/g, '</a></br><span class="ipsType_smaller desc lighter">')
                                        .replace(/\<\/td\>/g, '</span></div></li>')
                                        .replace(/\<td class="tcl tdtopics"\>/g, '<li class="ipsType_small clearfix"><img class="ipsUserPhoto ipsUserPhoto_mini left" alt="User image" src="http://i78.servimg.com/u/f78/18/17/62/92/defaul10.png"><div class="list_content">')
                                )
                                .find('span.status').remove();
                        } else {
                            if (oConfig.sExpression0) {
                                eval( oConfig.sExpression0 );
                            }
                            var sHtml = '';
                            oConfig.sTarget = memDiv.find(oConfig.sTarget);
                            jQuery.each(oConfig.sTarget, function( index, value ) {
                                sHtml +=
                                    '<li class="ipsType_small clearfix">' +
                                        '<img class="ipsUserPhoto ipsUserPhoto_mini left" alt="User image" src="http://i78.servimg.com/u/f78/18/17/62/92/defaul10.png">' +
                                        '<div class="list_content">' +
                                            eval( oConfig.sExpression1 ) + '<br>' +
                                            '<span class="ipsType_smaller desc lighter">' + eval( oConfig.sExpression2 ) + '</span>' +
                                        '</div>' +
                                    '</li>';
                            });
                            memDiv.html(sHtml);
                        }
                        jQuery('#user_inbox_link_menucontent ul.ipsList_withminiphoto').html(memDiv.html());
                        var oImgTarget = oTarget.find('.ipsType_small.clearfix');
                        oImgTarget.each(function( index ) {
                            var UserURL = jQuery(this).find('.ipsType_smaller a, .list_content a:last');
                            if (UserURL.length) {
                                UserURL = UserURL.attr('href');
                                var oImgTag = jQuery(this).find('.ipsUserPhoto');
                                var UserIMG = sessionStorage.getItem(UserURL); /* Gets the avatar saved in local storage */
                                /* If avatar alread saved, then no request member profile! */
                                if(UserIMG) {
                                    jQuery(this).find('img').attr('src', UserIMG);
                                } else {
                                    /* if not, then only request per session!!! */
                                    jQuery.get(UserURL, function(data){
                                        var profile_img = jQuery(oConfig.sGetIMG, data).attr('src');
                                        if (profile_img !== undefined) {
                                            oImgTag.attr('src', profile_img);
                                            /* Saves the member avatar in local storage */
                                            sessionStorage.setItem(UserURL, profile_img);
                                        }
                                    });
                                }
                            }
                        });
                    });
                }
                oTarget
                    .css({
                        'left': (oClicked.offset().left + oClicked.outerWidth()) - oTarget.outerWidth(),
                        'top': oClicked.offset().top + oClicked.outerHeight()
                    })          
                    .fadeIn(400);
                jQuery(document).mousedown(function() {
                    if(!oTarget.is(":hover")) {
                        jQuery(document).unbind('mousedown');
                        oClicked.removeClass('menu_active');
                        oTarget.fadeOut(400);
                    }
                });          
            } else {
                oClicked.removeClass('menu_active');
                oTarget.fadeOut(400);
            }
            return false;
        });
    });

Demo:

[Hỏi đáp] Giúp đỡ về code báo tin nhắn P9iCIZx

Cũng hay, nhưng mà quá phức tạp. Thật ra làm một thông báo khi có tin nhắn mà dùng cái này thì vừa dài dòng. tác dụng lại chẳng có bao nhiêu.

Chẳng thà kết hợp với popup của baivong thấy vừa hay vừa gọn lại còn đẹp hơn.
  Bài viết hay nhất10
You cannot reply to topics in this forum