带有 onclick java 脚本函数的输入按钮未触发

发布于 2024-12-10 13:51:47 字数 2590 浏览 0 评论 0原文

我的 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>
&nbsp;
        <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

My javascript button is not firing.

<!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>

Here's what i am trying. On click of the html button type. fb_publish should fire. This is just my trial.. Not sure if its supposed to work.
In the fb_publish() I have a FB.ui to post the textbox1.text and other event details to FB

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骄傲 2024-12-17 13:51:47

试试这个,将 id 添加到输入标记,并在文档加载后使用事件触发器。并在函数的开头放置一个警报以确保它被调用。

 <script> document.ready( function (){
    $('#fb_button').onClick( function(){
alert('button fired');
    fb_publish();
    }
    }
    </script>

try this, add and id to the input tag and use an event trigger once the document has loaded. and put an alert at the beginning of the function to make sure it's being called.

 <script> document.ready( function (){
    $('#fb_button').onClick( function(){
alert('button fired');
    fb_publish();
    }
    }
    </script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文