Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8317255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:33:03+00:00 2026-06-08T21:33:03+00:00

I have the following code on my site, which when it accesses Twitter’s API

  • 0

I have the following code on my site, which when it accesses Twitter’s API generates it’s own markup.

I’m looking to call a JavaScript function on the onClick even of this but, but as the markup changes it seems it’s not as simple as just adding an onClick to the anchor.

How can I capture the click of the ‘Tweet’ button?

<div class="social_button twitter_button">
  <a href="https://twitter.com/share" class="twitter-share-button" data-count="horizontal">
    Tweet
  </a>
  <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:33:05+00:00Added an answer on June 8, 2026 at 9:33 pm

    You can’t handle click events on this element, because it’s in an iFrame, however twitter gives you the opportunity to bind events to the button.

    Example: http://jsfiddle.net/ZwHBf/2/
    Docs: https://dev.twitter.com/docs/intents/events

    Code:
    HTML:

    <div class="social_button twitter_button">
        <div id="foo">
            <a href="https://google.com" class="twitter-share-button" data-count="horizontal">
        Tweet
      </a>
        </div>
        <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
        <script type="text/javascript" charset="utf-8">
            window.twttr = (function (d, s, id) {
                var t, js, fjs = d.getElementsByTagName(s)[0];
                if (d.getElementById(id)) return;
                js = d.createElement(s);
                js.id = id;
                js.src = "//platform.twitter.com/widgets.js";
                fjs.parentNode.insertBefore(js, fjs);
                return window.twttr || (t = {
                    _e: [],
                    ready: function (f) {
                        t._e.push(f)
                    }
                });
            }(document, "script", "twitter-wjs"));
        </script>
    </div>​
    

    JS:

    twttr.events.bind('click', function(event) {
        console.log('clicked');
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, written using jQuery: var strval = '22' $(#quicknote).attr(href, javascript:location.href=/'http://site.com/notes/add?projects=/'+
I have the following code (from a previous question on this site) which retrieves
I have the following code, which works fine on live site, but not on
I have the following javascript code: function initSite(){ var site; $.getJSON(www+'init/initSite', function(data) { site
I have the following code snippet: using (SPSite site = new SPSite(this.ListAddress)) { using
I have the following code, deployed on a https Asp site, build with MVC
From this site: http://www.toymaker.info/Games/html/vertex_shaders.html We have the following code snippet: // transformations provided by
I am working on a WordPress site and I have placed the following code
I have an ASP.NET web site with something similar to the following code: .aspx
I am writing code to performance test a web site. I have the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.