[英]How to Put Address bar url in href attribute
I have 1000 posts and want to put facebook comments on every page. 我有1000个帖子,并希望在每个页面上添加Facebook评论。 The facebook plguin requires a url value
inside the href
attribute. Facebook plguin在href
属性内需要一个url value
。 I don't want to manually put the url 1000 times. 我不想手动将网址放置1000次。
There are certain ways like putting expr:href='data:post.canonicaUrl'
in blogger.However, i am putting the code outside the main wrapper,hence blogger is unable to catch up the post url. 有某些方法,例如将expr:href='data:post.canonicaUrl'
中。但是,我将代码放在主包装程序之外,因此博客无法捕获帖子网址。
Is there anyway in which the href
attribute automatically catches up the value of the address bar url. 无论如何, href
属性会自动追上地址栏url的值。
Following script will replace the href
attribute of all anchor tags with the current url 以下脚本将所有锚标记的href
属性替换为当前网址
var anchors = document.getElementsByTagName('a');
for(var i=0;i<anchors.length;i++)
anchors[i].href = window.location.href;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.