[Tools] Add a Dynamic Tweet Button to a Webpage

To let people easily share the patio11bot, we‘ll add a "Tweet" button to the page. You can easily add a static share button by going to https://publish.twitter.com/ and following the instructions there, but to make a dynamic tweet button is more difficult.

We‘ll use the same share button, but we‘ll dynamically add it to the page with javascript, and then we have to tell the Twitter script to reload it as a widget with: twttr.widgets.load()

Insert the script into the header: 

<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

Add a placeholder in the html:

<div id="tweet-button"></div>

In script, we build dynamic message:

document.getElementById("tweet-button").innerHTML = ‘<a href="https://twitter.com/share?ref_src=twsrc%5Etfw" class="twitter-share-button" data-show-count="false" data-size="large" data-via="chrisachard" data-text="patio11bot.com just told me:\n\n‘+answer.quote+‘\n\nWhat will it tell you?">Tweet</a>‘

twttr.widgets.load()

原文地址:https://www.cnblogs.com/Answer1215/p/10353429.html

时间: 2024-11-13 09:56:34

[Tools] Add a Dynamic Tweet Button to a Webpage的相关文章

Tweet button with a callback – How to?

原文: http://jaspreetchahal.org/tweet-button-with-a-callback-how-to/ 两种方式:1. 原生的button <a href="https://twitter.com/share" class="twitter-share-button" data-via="zjh1" data-lang="zh-cn" data-size="large"&

ef code first transform,add ef power tools add-in,add tangible t4 editor for enhancement.

use ef power tools, as to .edmx file,right click at view, choose generate database from model, then copy the generated sql text, run the text in database, use ef power tools add in to generate mappings for code first usage.

Linux Programe/Dynamic Shared Library Entry/Exit Point &amp;&amp; Glibc Entry Point/Function

目录 1. 引言 2. C/C++运行库 3. 静态Glibc && 可执行文件 入口/终止函数 4. 动态Glibc && 可执行文件 入口/终止函数 5. 静态Glibc && 共享库 入口/终止函数 6. 动态Glibc && 共享库 入口/终止函数 1. 引言 0x1: glibc Any Unix-like operating system needs a C library: the library which defines t

[AngularJS] Accessible Button Events

Often buttons need to be handled by JavaScript, and if done improperly it can lead to accessibility issues. In this lesson you will improve a major news organization's global header with some basic HTML and JavaScript. Normal you should use native 'b

android shape图形优化Button效果

android shape可以让我们通过定义xml文件的方式创建图形,当然只能实现一些比较简单的图形(圆形,矩形,椭圆,线段),但是已经相当不错了,通过shape创建的图形作为控件的背景已经基本可以满足我的简单需求了,而且通过shape创建的图形可以适配各种屏幕. 下面就用shape定义的图形来优化Button的整体效果. 定义主布局文件activity_main.xml: 1 <RelativeLayout xmlns:android="http://schemas.android.co

2016/3/26 连接数据库 网页中数据的增删改 add delete update addchuli updateChuLi test8 DBDA

主页面 test8.php 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 </head> 7 <body> 8 <table width=100% border="1" cellpadding=&

Dynamic proxy

package proxy; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; /** * Created by 10159705 on 16-1-8. */ public class DynamicProxyTest { interface IHello { void sayHello(); } static class Hel

ASP.NET 动态创建文本框 TextBox (add TextBox to page dynamically)

下面的函数每执行一次就生成一个TextBox(其实是<input type="Text">) var i=0;    function changeIt()    {    if(i<5)    {        i=i+1;        skils='skill'+i;        my_div.innerHTML = my_div.innerHTML +" <input type='text' id='" + skils + &quo

[Xamarin] button及事件处理

在visual studio + Genymobile 的调试环境下,遇到连不上虚机的情况,在Xamarin官方论坛上找到解决方案,如下: 主要就是去android的project属性调整几个值 Couldn't connect to logcat, GetProcessId returned: 0 Open your application properties Android Manifest -->Required Permission -->Enable ACCESS_COARSE_L