给每篇文章结尾添加一段文字
/** * 给每篇文章结尾添加一段文字 * 代号:jopaisdfj892345.js * * @param {Object} func * @param {Object} times * @param {Object} interval */jQuery.fn.wait = function (func, times, interval) { var _times = times || -1, //100次 _interval = interval || 20, //20毫秒每次 _self = this, _selector = this.selector, //选择器 _iIntervalID; //定时器id if (this.length) { //如果已经获取到了,就直接执行函数 func && func.call(this); } else { _iIntervalID = setInterval(function query() { if (!_times) { //是0就退出 clearInterval(_iIntervalID); } _times <= 0 || _times--; //如果是正数就 -- _self = $(_selector); //再次选择 if (_self.length) { //判断是否取到 func && func.call(_self); clearInterval(_iIntervalID); } }, _interval); } return this;}function focusFunction(){ var _targetTop = $('#comment_form_container').offset().top;//获取位置 jQuery("html,body").animate({scrollTop:_targetTop},300);//跳转}function focusFollow(){ var _targetTop = $('#profile_block').offset().top;//获取位置 jQuery("html,body").animate({scrollTop:_targetTop},300);//跳转}$(document).ready(function(){ $(" ").appendTo($("body")).bind("click", function(){ $("body,html").animate({ scrollTop: 0 }, 150); }); $('#cnblogs_post_body pre').find('>code').parent().css({'border':'dashed 1px #aaa','border-left':'solid 2px #6CE26C'}); $("#cnblogs_post_body").append('这是是需要添加的文字这里是需要添加的文字');});//js截取字符串,中英文都能用 //如果给定的字符串大于指定长度,截取指定长度返回,否者返回源字符串。 //字符串,长度 /** * js截取字符串,中英文都能用 * @param str:需要截取的字符串 * @param len: 需要截取的长度 */function cutstr(str, len) { var str_length = 0; var str_len = 0; str_cut = new String(); str_len = str.length; for (var i = 0; i < str_len; i++) { a = str.charAt(i); str_length++; if (escape(a).length > 4) { //中文字符的长度经编码之后大于4 str_length++; } str_cut = str_cut.concat(a); if (str_length >= len) { str_cut = str_cut.concat("..."); return str_cut; } } //如果给定字符串小于指定长度,则返回源字符串; if (str_length < len) { return str; }}
CSS 文件:
/** * 给每篇文章添加一个目录导航 * *//*定义整个目录框架的大小*/ #sideToolbar { position: fixed; bottom: 105px; right: 125px; width: 200px; height: 250px;}#sideCatalog{ background-color:#fff; padding-bottom:10px; border-radius:5px;}#sideCatalog-sidebar { -moz-border-bottom-colors: none; -moz-border-left-colors: none; -moz-border-right-colors: none; -moz-border-top-colors: none; background-color: #eaeaea; border-color: -moz-use-text-color #eaeaea; border-image: none; border-left: 1px solid #eaeaea; border-right: 1px solid #eaeaea; border-style: none solid; border-width: 0 1px; height: 250px; left: 5px; position: absolute; top: 0; width: 0}/*目录形成的范围*/ #sideCatalog-catalog { height: 250px; padding-top: 18px; overflow-x: hidden; overflow-y: scroll; padding-left: 5px; position: relative; background: url("http://files.cnblogs.com/files/anstoner/bg_body.gif") 0 50% no-repeat;}#sideCatalog #sideCatalog-sidebar .sideCatalog-sidebar-top { cursor: pointer; top: 0}#sideCatalog #sideCatalog-sidebar .sideCatalog-sidebar-bottom { bottom: 0}#sideCatalog #sideCatalog-sidebar .sideCatalog-sidebar-top,#sideCatalog #sideCatalog-sidebar .sideCatalog-sidebar-bottom { background: url("http://files.cnblogs.com/files/anstoner/list_sideToolbar.gif") no-repeat scroll 0 -199px transparent; height: 10px; left: -5px; overflow: hidden; position: absolute; width: 10px}#sideCatalog li { margin: 2px; padding: 0 7px; text-align: left; position: relative}#sideCatalog li:hover { background-color: #f5f5f5}#sideCatalog-catalog ul.active { background-color: #f5f5f5}#sideCatalog-catalog .active a { color: #519cea;}#sideCatalog-catalog a:hover { color: #519cea;}#sideCatalog span:first-child { color: #999; font-family: Arial; font-size: 14px; font-weight: bold; padding-right: 5px;}/*这里比较重要,设置h2级别目录的缩进和左边距*/ #sideCatalog li.h2Offset { padding-left: 35px; text-indent: -25px}/*这里比较重要,设置h3级别目录的缩进和左边距*/#sideCatalog li.h3Offset { padding-left: 80px; text-indent: -60px}#sideCatalog a { text-decoration: none; color: #555; font-weight: bold}.sideCatalog-dot { background: url("http://files.cnblogs.com/files/anstoner/list_sideToolbar.gif") repeat scroll 0 -222px transparent; cursor: pointer; font-size: 12px; height: 10px; left: -6px; line-height: 12px; overflow: hidden; position: absolute; top: 4px; width: 6px}#sideCatalog .highlight .sideCatalog-dot { background: url("http://files.cnblogs.com/files/anstoner/list_sideToolbar.gif") no-repeat scroll -271px -38px transparent; height: 13px; left: -23px; top: 3px; width: 18px}#sideCatalogBtn { background: url("http://files.cnblogs.com/files/anstoner/list_sideToolbar.gif") no-repeat scroll 0 0 transparent; cursor: pointer; display: block; height: 45px; margin-bottom: 5px; margin-left: 5px; position: relative; width: 45px; margin-top: 10px; outline: 0}#sideCatalogBtn:hover { background: url("http://files.cnblogs.com/files/anstoner/list_sideToolbar.gif") no-repeat scroll -154px 0 transparent}.sideCatalogBtnDisable { background: url("http://files.cnblogs.com/files/anstoner/list_sideToolbar.gif") no-repeat scroll -104px 0 transparent !important}#sideToolbar-up { background: url("http://files.cnblogs.com/files/anstoner/list_sideToolbar.gif") no-repeat scroll -1px -62px transparent; border-radius: 2px; display: block; height: 45px; margin-left: 5px; width: 45px; outline: 0}#sideToolbar-up:hover { background: url("http://files.cnblogs.com/files/anstoner/list_sideToolbar.gif") no-repeat scroll -74px -62px transparent}
给每篇文章添加一个目录导航