我有以下的Facebook iframe的作为模板的一部分:如何在使用Blogspot变量的Blogspot模板中有脚本?
<iframe allowTransparency='true' expr:src='"http://www.facebook.com/plugins/like.php?href=" + data:post.url + "&layout=standard&show_faces=false&width=100&action=like&font=arial&colorscheme=light"' frameborder='0' scrolling='no' style='border:none; overflow:hidden; width:576px; height:24px;'/>
的主要特点是,它采用的Blogspot变量data:post.url
的链接,用户可以“赞”。不幸的是,最近blogspot决定将用户重定向到当地blospot地址,所以如果您在英国打开example.blogspot.com
,您将被重定向到example.blogspot.co.uk
,并且您看不到任何来自岛外的人的喜好。
最明显的解决方法是让每个人都像主.COM页面,所以我创建了一个脚本生成动态此iframe:
<script type="text/javascript">
document.write("<iframe allowTransparency='true' frameborder='0' scrolling='no' src='http://www.facebook.com/plugins/like.php?href=");
var thisUrl = "data:post.url";
var beginning = thisUrl.indexOf("blogspot")+9;
var end = thisUrl.indexOf("/", 15);
document.write(thisUrl.substring(0, beginning));
document.write("com");//change regional url to com
document.write(thisUrl.substring(end));
document.write("&layout=standard&show_faces=false&width=100&action=like&font=arial&colorscheme=light' style='border:none; overflow:hidden; width:576px; height:24px;'></iframe>");
</script>
为了Blogspot的接受它,我不得不HTML的ecape它位,但我无法将变量data:post.url
替换为正确的值 - 它保持字面意思。
回复2:因为我希望它也可以用于主博客页面(列出一些最新的博客条目)。 – Grzenio