将图像链接到帖子网址

时间:2013-09-29 14:13:01

标签: javascript html image blogger

我有一个自定义博客模板,显示主页上帖子的图片和帖子标题(链接到帖子)。 我需要做的是将该图像链接到帖子网址,我已经累了链接图像,但整个代码中断了

下面是头部

中的java脚本代码
<script type='text/javascript'>
var thumbnail_mode = &quot;float&quot; ;
summary_noimg = 250;
summary_img = 250;
</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)!=' ' && 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 = '<div class="crop"><img src="'+img[0].src+'" width="300px;" height="350px;"/></div>';
summ = summary_img;
}
var summary = imgtag + '<div class="posting">' + '</div>';
div.innerHTML = summary;
}
//]]>
</script>

正文部分中的代码

<div class='cover'>
<a expr:name='data:post.id'/>
    <b:if cond='data:post.title'>
      <h2>
     <b:if cond='data:post.link'>
       <a expr:href='data:post.link' expr:title='&quot;Permanent Link to &quot; + data:post.title' rel='bookmark'><data:post.title/></a>
     <b:else/>
        <b:if cond='data:post.url'>
          <a expr:href='data:post.url' expr:title='&quot;Permanent Link to &quot; + data:post.title' rel='bookmark'><data:post.title/></a>
        <b:else/>
          <data:post.title/>
        </b:if>
     </b:if>
      </h2>
    </b:if>


<div class='jomore'><div class='jomorelink'><a class='anes' expr:href='data:post.url'>&#9658;</a></div></div>
        <div class='bgjo'><div expr:id='&quot;summary&quot; + data:post.id'><a expr:href='data:post.url'><data:post.body/></a></div></div>
        <script type='text/javascript'>createSummaryAndThumb(&quot;summary<data:post.id/>&quot;);</script>
        <div style='clear: both;'/> <!-- clear for photos floats -->
      </div>

1 个答案:

答案 0 :(得分:0)

在java代码中

替换此

if(img.length>=1) {
  imgtag = '<div class="crop"><img src="'+img[0].src+'" width="300px;" height="350px;"/></div>';
summ = summary_img;

if(img.length>=1) {
  imgtag = '<div class="crop"> <a expr:href='data:post.link' ><img src="'+img[0].src+'" width="300px;" height="350px;"/></a></div>';
summ = summary_img;