为什么我的Facebook“赞"按钮坏了? [英] Why is my Facebook Like button broken?

查看:87
本文介绍了为什么我的Facebook“赞"按钮坏了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了一些与我所遇到的问题类似的问题,但是我所见过的所有解决方案都没有用,包括Facebook皮棉工具.我的Facebook生成的代码,以window.location的escape()为模,目前已被注释掉,并且几乎包含一个裸露的JavaScript,包括:

I've seen a couple of problems similar to what I'm having, but none of the solutions I've seen work, including the Facebook lint tool. My Facebook-generated code, modulo an escape() of window.location, is presently commented out, and is in what is almost a bare JavaScript include:

document.write('<iframe src="http://www.facebook.com/plugins/like.php?app_id=142676242492854&amp;href=' + escape(url) + '&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font=verdana&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:167px; height:40px;" allowTransparency="true"></iframe>');

或基于皮棉工具的另一个:

or the other one based on the lint tool:

document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=' + escape(url) + " scrolling="no" frameborder="0" style="height: 62px; width: 100%" allowTransparency="true"></iframe>');

有几处调整的地方,就是我只想要一个裸露的按钮,没有关于单击该按钮的朋友的注释,但是我还不喜欢它.我还有另一个问题.

There are a couple of tuning things in that I just want a bare button, no annotations about friends who've clicked the button, but I'm not fiddling with that just yet; I have another problem.

如果单击该按钮,它会立即改变并说您喜欢它;但按钮的背景并未从浅灰色变为蓝色.此外,它不会卡住整个页面重新加载.

If you click the button, it changes momentarily and says that you like it; but the button does not turn from light grey to blue for its background. Furthermore, it does not stick across a page reload.

是否可以/应该将上面的JavaScript替换为包含可正常使用的Like按钮的代码?该站点位于 http://JonathansCorner.com ,并且该行代码(已注释)是整个站点包含的JavaScript.

Is there code I can/should replace the above JavaScript with to include a working Like button? The site is at http://JonathansCorner.com and the line of code is (commented out in) a sitewide JavaScript include.

推荐答案

document.write很邪恶,请不要使用它.

document.write is evil, don't use it.

如果它是静态页面(您的网站似乎是静态页面),则只需将iframe添加到您想要的HTML正文中即可.

If it's a static page (which your site seems to be) then just add the iframe in the body of the HTML where you want it.

如果您确实要在JS中添加按钮客户端,请使用JS SDK( https: //developers.facebook.com/docs/reference/javascript ),然后添加按钮,如下所示:

If you really want to add the button client side in JS, use the JS SDK ( https://developers.facebook.com/docs/reference/javascript ) and add the button like so:

var dynLike = document.createElement('fb:like');
dynLike.setAttribute('href', myEncodedURL);
dynLike.setAttribute('send', 'false');
dynLike.setAttribute('width', '450');
dynLike.setAttribute('show_faces', 'false');
document.body.appendChild(dynLike); // Or wherever you want it
FB.XFBML.parse();

这篇关于为什么我的Facebook“赞"按钮坏了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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