博客园设置目录记录

设置主题

SimpleMemory

设置页脚HTML

<script language="javascript" type="text/javascript">
    function GenerateContentList(h23) {
        var mainContent = $('#cnblogs_post_body');
        var h2_list = $('#cnblogs_post_body').children(h23);
 
        if (mainContent.length < 1)
            return;
 
        if (h2_list.length > 0) {
            var content = '<a name="_labelTop"></a>';
            content += '<div id="navCategory">';
            content += '<p id="mylist" style="font-size:30px"><b>目录</b></p>';
            content += '<ul id="myul"><li style="text-align: right"><b id="guanbi" style="cursor: pointer">x</b></li>';
            for (var i = 0; i < h2_list.length; i++) {
                var go_to_top = '<div style="text-align: right"><a href="#_labelTop">Top~~</a><a name="_label' + i + '"></a></div>';
                $(h2_list[i]).before(go_to_top);
 
                var h3_list = $(h2_list[i]).nextAll("h3");
                var li3_content = '';
                for (var j = 0; j < h3_list.length; j++) {
                    var tmp = $(h3_list[j]).prevAll('h2').first();
                    if (!tmp.is(h2_list[i]))
                        break;
                    var li3_anchor = '<a name="_label' + i + '_' + j + '"></a>';
                    $(h3_list[j]).before(li3_anchor);
                    li3_content += '<li><a href="#_label' + i + '_' + j + '">' + $(h3_list[j]).text() + '</a></li>';
                }
 
                var li2_content = '';
                if (li3_content.length > 0)
                    li2_content = '<li><a href="#_label' + i + '">' + $(h2_list[i]).text() + '</a><ul>' + li3_content + '</ul></li>';
                else
                    li2_content = '<li><a href="#_label' + i + '">' + $(h2_list[i]).text() + '</a></li>';
                content += li2_content;
            }
            content += '</ul>';
            if ($('#cnblogs_post_body').length != 0) {
                $($('#cnblogs_post_body')[0]).prepend(content);
            }
        }
    }
 
    if ($('#cnblogs_post_body h2').length > 0) {
        GenerateContentList('h2');
    } else {
        GenerateContentList('h3');
    }
    jQuery('#mylist').click(function () {
        var my_list = jQuery(this);
        var my_mulu = jQuery('#myul');
        my_list.stop();
        my_mulu.stop();
        my_list.slideUp(400);
        my_mulu.fadeIn(600);
    });
    $('#guanbi').click(function () {
        var my_list = jQuery('#mylist');
        var my_mulu = jQuery('#myul');
        my_list.stop();
        my_mulu.stop();
        my_list.slideDown(400);
        my_mulu.fadeOut(600);
    })
</script>

设置页面CSS样式

#navCategory {
    position: fixed;
    right: 0;
    top: 100px;
    list-style: none;
    z-index: 99999;
}
 
#navCategory > #mylist {
    position: absolute;
    background-color: white;
    width: 32px;
    left: -32px;
    font-size: 30px;
    font-weight: bold;
    border-radius: 5px;
    opacity: 0.8;
}
 
#navCategory > #myul {
    background-color: white;
    height: 400px;
    width: 230px;
    padding-top: 5px;
    overflow: auto;
}
 
#navCategory ul, #navCategory li {
    list-style: none !important;
    margin: 5px !important;
}
posted @   寒小韩  阅读(37)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示