Why is my Facebook Like button broken?

久未见 提交于 2019-12-01 14:21:43

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

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.

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();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!