Javascript 如何在Facebook上触发点击事件';比如';按钮
我正在尝试运行以下代码,这些代码取自Facebook开发者网站。我在“你喜欢…”中输入的警告没有出现。我做错了什么Javascript 如何在Facebook上触发点击事件';比如';按钮,javascript,facebook,Javascript,Facebook,我正在尝试运行以下代码,这些代码取自Facebook开发者网站。我在“你喜欢…”中输入的警告没有出现。我做错了什么 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://o
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<div id="Div1">
</div>
<script type="text/javascript">
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));</script>
<form id="form1" runat="server">
<div>
<div id="fb-root">
</div>
<fb:like href="www.goal.com" send="true" width="450" show_faces="true">
</fb:like>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
status: true, // Check login status.
cookie: true, // Enable cookies to allow the server to access the session.
xfbml: true // Parse XFBML.
});
</script>
<script type="text/javascript">
FB.Event.subscribe('edge.create',
function (response) {
alert('You liked the URL: ' + response);
});
</script>
</div>
</form>
</body>
</html>
(功能(d、s、id){
var js,fjs=d.getElementsByTagName[0];
if(d.getElementById(id)){return;}
js=d.createElement;js.id=id;
js.src=“//connect.facebook.net/en_US/all.js#xfbml=1”;
fjs.parentNode.insertBefore(js,fjs);
}(文档“脚本”、“facebook jssdk”);
FB.init({
状态:true,//检查登录状态。
cookie:true,//启用cookie以允许服务器访问会话。
xfbml:true//解析xfbml。
});
FB.Event.subscribe('edge.create',
功能(响应){
警报(“您喜欢URL:”+响应);
});
它没有什么问题。它确实起作用。当我点击like按钮时,警报就出现了
只是一点提示:您应该在页面的
部分添加
标记。没有问题。它确实起作用。当我点击like按钮时,警报就出现了
只是一点提示:您应该在页面的
部分放置
标记。Facebook很奇怪,脚本标记根据文档正确放置。@RobinJ登录出现,但警报没有出现?Facebook很奇怪,脚本标记已根据文档正确放置。@RobinJ会出现登录,但警报不会出现?在调用connect JS后添加。在调用connect JS后添加。