<script type="text/javascript">
//<![CDATA[
function mycallbackk(e) {
for (var i = 0; i < e.feed.entry.length; i++) {
var d = e.feed.entry[i];
contentcontent = d.content.$t;
var divvv = document.createElement("div");
divvv.innerHTML = contentcontent;
var imggg = divvv.getElementsByTagName("a")[1];
function printRelatedLabels_thumbs() {
for (var j = 0; j < d.link.length; j ++) {
if (d.link[j].rel == 'alternate') {
var purl = d.link[j].href;
break;
}
}
var title = d.title.$t,
author = d.author[0].name.$t,
tag = d.category[0].term,
img = d.media$thumbnail.url;
var itemerwsds = ("<img src="+ img +"></img><h3><a href="+ purl +">"+ title +"<a/></h3><div class='post-infooo'><a>"+ tag +"</a><a>"+ author +"</a></div><div>" + imggg + "</div>");
document.write(itemerwsds);
}
}
}
//]]>
</script>
当我选择这样的链接&gt;&gt;&gt;&gt;它的工作原理
<script src="http://templatertl.blogspot.com/feeds/posts/default/-/gooo?max-results=3&alt=json-in-script&callback=mycallbackk"></script>
=====================
但是当添加这样的变量&gt;&gt;&gt;&gt;它不起作用
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.isLast != "true"'>
</b:if>
<b:if cond='data:blog.pageType == "item"'>
<script expr:src='"/feeds/posts/default/-/" + data:label.name + "?alt=json-in-script&callback=mycallbackk&max-results=3"' type='text/javascript'/>
</b:if>
</b:loop>
如何使用变量链接?
答案 0 :(得分:2)
如果在Blog Widget data:post.labels
标记之外使用,则数据布局标记b:widget
将返回空,因为未定义post
命名空间。
如果您希望代码在移动设备上运行,请在<b:includable id='post' var='post'>
(和<b:includable id='mobile-post' var='post'>
块中包含脚本块)在Blog小部件中显示