capture the click of the Twitter “Tweet” button using jQuery

前端 未结 3 1435
南笙
南笙 2021-01-03 04:02

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 onCli

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-03 04:40

    Adding a customized Twitter button to your website is a lot easier than you might think.

    Tweet
    

    Yes, really, that's all it takes. Give your link some design love and tada! Your very own custom Twitter button.

    Opening the Twitter Share Box in a popup window

    To show the Twitter Share Box as a popup, simply add some lines of javascript to open the link in a new window. Here's an example using jQuery:

    
    
    
    

    Note: This is just an example. You'll probably want to put the javascript code in a .js file and call it on document ready.

    $(document).ready(function() {
      $('.popup').click(function(event) {
        // and so on...
      }
    });
    

    Setting a default message for the tweet

    You can set a default text for the tweet adding a text parameter to the link:

    
    

    Now when your users click on your Tweet link, the message "This is so easy" will appear in the tweet box by default. more..

提交回复
热议问题