2018年12月20日星期四

Blogger如何使主页帖子为预览模式而不是全文显示?

简单来说就是:需要编辑blog的html。

把javascript这段代码添加到······段里。(末尾就好啦)
<script type="text/javascript">
img_thumb_width = 180; // Image Thumbnail Width
img_thumb_height = 180; // Image Thumbnail Height
summary_noimg = 500; // Length of Summary Text if no image is Used
summary_img = 400; // Length of Summary Text if post has Image Thumbnail
</script>
<script type="text/javascript">
//<![CDATA[
function removeHtmlTag(strx,chop){
if(strx.indexOf("<")!=-1)
{
var s = strx.split("<");
for(var i=0;i<s.length;i++){
if(s[i].indexOf(">")!=-1){
s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length);
}
}
strx = s.join("");
}
chop = (chop < strx.length-1) ? chop : strx.length-2;
while(strx.charAt(chop-1)!=' ' &amp;&amp; strx.indexOf(' ',chop)!=-1) chop++;
strx = strx.substring(0,chop-1);
return strx+'...';
}
function createSummaryAndThumb(pID){
var div = document.getElementById(pID);
var imgtag = "";
var img = div.getElementsByTagName("img");
var summ = summary_noimg;
if(img.length>=1) {
imgtag = '<span style="overflow:hidden; border: none; margin:0 15px 10px 0; float:left; max-height:'+img_thumb_height+'px;width:auto;"><img src="'+img[0].src+'" width="'+img_thumb_width+'px" height="auto"/></span>';
summ = summary_img;
}
var summary = imgtag + '<div>
' + removeHtmlTag(div.innerHTML,summ) + '</div>
';
div.innerHTML = summary;
}
//]]>
</script>

Ctrl+F搜索 用下面列出的这段html代码 去替换这一小丢代码 (替换所有能找到的)
<data:post .body=""> </data:post>

用下面这段代码把上面这部分替换掉

<b:if cond="data:blog.pageType == &quot;static_page&quot;">

<data:post .body="">
<b:else>
<b:if cond="data:blog.pageType != &quot;item&quot;">
<div expr:id="&quot;summary&quot; + data:post.id">
<data:post .body=""></data:post></div>
<script type="text/javascript">createSummaryAndThumb("summary<data:post.id/>");
</script>  
<span class="jump-link" style="float: right; padding-top: 20px;"><a expr:href="data:post.url + &quot;#more&quot;" expr:title="data:post.title" href="https://www.blogger.com/null"><data:post .jumptext=""></data:post></a></span>
</b:if>
<b:if cond="data:blog.pageType == &quot;item&quot;"><data:post .body=""></data:post></b:if>
</b:else></data:post></b:if>
阅读更多博文 »

最新评论