我有以下Facebook iframe作为模板的一部分:
<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;'/>它的主要特点是,它使用博客变量data:post.url作为链接,用户可以“喜欢”。不幸的是,博客点最近决定将人们重定向到他们当地的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>为了让博客斑点接受它,我不得不对它进行html-ecape,但是我不能把变量data:post.url替换成一个正确的值--它保持原样。
发布于 2012-06-17 19:46:36
要显示Blogger变量,您需要使用<data:blog.varName/>。
因此,在您的情况下,而不是:
var thisUrl = "data:post.url";您需要使用:
var thisUrl = "<data:post.url/>";更新1:如果您想在head部分使用页面url,请使用<data:blog.url/>而不是<data:post.url/>。
更新2:但是为什么不使用window.location呢
发布于 2012-06-17 19:17:17
格泽尼奥。
这不能直接回答您的问题,但您可以使用
用data:post.canonicalUrl替换data:post.url
这意味着你所有喜欢的东西都将使用你的博客的.com版本。
所以你不需要使用任何javascript等等。
https://stackoverflow.com/questions/11001586
复制相似问题