Facebook的喜欢/股当前的URL [英] Facebook like/share current URL

查看:106
本文介绍了Facebook的喜欢/股当前的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图解决现在这个几天。基本上我有使用Facebook的开发工具生成我的网站像/共享按钮。所以这是非常标准。但我不能让它像/股当前的URL。

 < D​​IV CLASS =FB-样COL-XS-偏移1数据布局=标准数据动作=喜欢的数据显示,面孔=真正的数据共享=真正的>< / DIV>

我曾尝试:

1)使用数据HREF =<%= Request.Url.AbsoluteUri%GT;

2)设置数据HREF 使用JavaScript使用 window.location的

3)离开数据HREF 空。现在,这是说工作,但它不适合我。不过,我怀疑这是因为我在本地主机上运行,​​会是什么原因?

当我尝试这些方法它给了我这个链接之前,我实际的股权分窗口:

<$p$p><$c$c>https://www.facebook.com/v2.2/plugins/like.php?action=like&app_id=78205603350&channel=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter%2FrFG58m7xAig.js%3Fversion%3D41%23cb%3Df2283ae550ed898%26domain%3Dlocalhost%26origin%3Dhttp%253A%252F%252Flocalhost%253A59928%252Ff3ee4865310c9fa%26relation%3Dparent.parent&container_width=1237&href=http%3A%2F%2Flocalhost%3A59928%2FDefault&layout=standard&locale=en_US&sdk=joey&share=true&show_faces=true

,然后当我$下一个P $ PSS和来实际共享窗口它试图分享www.facebook.com


解决方案

1)必须是&LT;%=

 数据HREF =&LT;%= Request.Url.AbsoluteUri%GT;

2)你可以做

 &LT; D​​IV ID =sharebutton
...在window.onload =函数(){
    VAR CURRENTURL = window.location.href;
    的document.getElementById(sharebutton)的setAttribute(数据HREF,CURRENTURL)。
} - 或者使用jQueryjQuery的(文件)。在('准备好',函数($){
    VAR URL = window.location的;
    $('。FB状COL-XS-偏移-1')ATTR('数据的href',URL)。
});

3)离开数据的href空白的社交插件的2.0版之前的工作。

您不能共享本地主机。你需要测试生产服务器上的共享按钮,你将拥有真正的网址

I have been trying to solve this for a few days now. Basically I have a like/share button on my site generated using the facebook developer tool. So it is very standard. But I can't get it to like/share the current URL.

<div class="fb-like col-xs-offset-1" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"></div> 

What I have tried:

1) Using data-href =" <%= Request.Url.AbsoluteUri %> "

2) Setting data-href using javascript using window.location

3) Leaving data-href empty. Now this is said to work, but it does not for me. However I suspect this is because I am running on localhost, could that be why?

When I try these methods it gives me this link before I get to the actual share-window:

https://www.facebook.com/v2.2/plugins/like.php?action=like&app_id=78205603350&channel=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter%2FrFG58m7xAig.js%3Fversion%3D41%23cb%3Df2283ae550ed898%26domain%3Dlocalhost%26origin%3Dhttp%253A%252F%252Flocalhost%253A59928%252Ff3ee4865310c9fa%26relation%3Dparent.parent&container_width=1237&href=http%3A%2F%2Flocalhost%3A59928%2FDefault&layout=standard&locale=en_US&sdk=joey&share=true&show_faces=true

And then when I press next and come to the actual sharing-window it tries to share "www.facebook.com"

解决方案

1) Must be <%=

data-href="<%=Request.Url.AbsoluteUri%>"

2) You could do

<div id="sharebutton"
...

window.onload = function () {
    var currentUrl = window.location.href;
    document.getElementById("sharebutton").setAttribute("data-href", currentUrl);
}

-- or using jquery

jQuery(document).on('ready', function($){
    var url = window.location;  
    $('.fb-like col-xs-offset-1').attr('data-href', url);
});

3) Leaving data-href "" blank worked before v2.0 of social plugin

You can't share localhost. You need to test your share-button on production server where you would have real URL

这篇关于Facebook的喜欢/股当前的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆