我的javascript按钮没有触发。
<!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">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<div>
<script language="javascript" type="text/javascript">
FB.init({
appId: '185176734893804',
status: true,
cookie: true,
xfbml: true
});
function fb_publish() {
FB.ui(
{
method: 'stream.publish',
message: document.getElementById('<%=TextBox1.ClientID%>').value,
attachment: {
name: 'Friends Gathering',
caption: 'Healthy living',
description: (
'Your welcome to join us on the event'
),
href: 'thomasblog.somee.com'
},
action_links: [
{ text: 'document.getElementById('<%=TextBox1.ClientID%>').value', href: 'thomasblog.somee.com' }
],
user_prompt_message: 'Personal message here'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
</script>
</div>
<div>
Event Date:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
Event Title:
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Add Event" />
<br />
<br />
<asp:Calendar ID="Calendar1" runat="server" BackColor="White"
<TitleStyle BackColor="White" BorderColor="Black" BorderWidth="2px"
Font-Bold="True" Font-Size="12pt" ForeColor="#333399" />
</asp:Calendar>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<input type="button" onclick="fb_publish()"
value ="Post To facebook Wall" />
</div>
</form>
</body>
</html>
这是我正在尝试的。点击html按钮类型。 fb_publish应该开火。这只是我的试用..不确定它是否应该起作用。 在fb_publish()中,我有一个FB.ui将textbox1.text和其他事件详细信息发布到FB
答案 0 :(得分:0)
尝试这个,添加和id到输入标记,并在文档加载后使用事件触发器。并在函数的开头发出警报,以确保它被调用。
<script> document.ready( function (){
$('#fb_button').onClick( function(){
alert('button fired');
fb_publish();
}
}
</script>