[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()
[Tools] Add a Dynamic Tweet Button to a Webpage的更多相关文章
- Using jQuery to add a dynamic “Back To Top” floating button with smooth scroll
Ever read a really long blog post or article and then had to scroll all the way up to the top of the ...
- Tweet button with a callback – How to?
原文: http://jaspreetchahal.org/tweet-button-with-a-callback-how-to/ 两种方式:1. 原生的button <a href=&quo ...
- 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 ...
- Linux Programe/Dynamic Shared Library Entry/Exit Point && Glibc Entry Point/Function
目录 . 引言 . C/C++运行库 . 静态Glibc && 可执行文件 入口/终止函数 . 动态Glibc && 可执行文件 入口/终止函数 . 静态Glibc & ...
- magento产品成功添加到购物车后跳转到不同页面 添加 add to cart 按钮
1 添加产品到购物车成功后是跳转到购物车页面或不跳转.这个在后台可以设置 system -> configuration -> After Adding a Product Redirec ...
- [AngularJS] Accessible Button Events
Often buttons need to be handled by JavaScript, and if done improperly it can lead to accessibility ...
- 在toolbar里动态创建多个button(ext.net)
private void setOneMenu() { string sql = "select id,name,gids from Config where name<>'高级 ...
- Dynamic proxy
import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflec ...
- ASP.NET 动态创建文本框 TextBox (add TextBox to page dynamically)
下面的函数每执行一次就生成一个TextBox(其实是<input type="Text">) var i=0; function changeIt() ...
随机推荐
- NoSQL 数据库应用
类型 部分代表 特点 列存储 Hbase Cassandra Hypertable 顾名思义,是按列存储数据的.最大的特点是方便存储结构化和半结构化数据,方便做数据压缩,对针对某一列或者某几列的查 ...
- 原本就有mysql,安装phpstudy使用里面自带的mysql导致原来的没服务
电脑中之前安装了mysql,正常服务中,但做项目的需要,安装了phpStudy,它里面自带了mysql,启动phpstudy里面的mysql后在用原来的就没服务了, 到电脑管理服务中也没有发现mysq ...
- 转:fortios 5.4后门植入
提示: 1.经过实验,fortios 5.4 beta4也是可以的. 2.在实验时,选择先下载fortios 5.2(做了快照),再升级5.4,则虚拟机挂载需要选择FortiGate-VM-disk1 ...
- 转:python cgi编程
转:http://www.runoob.com/Python/python-cgi.html 什么是CGI CGI 目前由NCSA维护,NCSA定义CGI如下: CGI(Common Gateway ...
- windows同时使用python2和3
前言 手头有些脚本,有些是在python2的环境下使用,有些是在python3的环境下使用 以前我是把python3的脚本都放在虚拟机中,现在发现是真的麻烦,于是来研究一下如何使得python2和3共 ...
- 洛谷P4302 [SCOI]字符串折叠 [字符串,区间DP]
题目传送门 字符串折叠 题目描述 折叠的定义如下: 一个字符串可以看成它自身的折叠.记作S = S X(S)是X(X>1)个S连接在一起的串的折叠.记作X(S) = SSSS…S(X个S). 如 ...
- linux——(2)文件权限与目录配置
概念一:用户与用户组 对linux下的每一个文件或者目录来说,访问者都有三种身份:所有者,用户组,其他人.这三种人对于同一个文件的权限是可以分开设定的. 概念二:linux文件权限 文件和目录都有3种 ...
- 【BZOJ 1095】 1095: [ZJOI2007]Hide 捉迷藏 (括号序列+线段树)
1095: [ZJOI2007]Hide 捉迷藏 Description 捉迷藏 Jiajia和Wind是一对恩爱的夫妻,并且他们有很多孩子.某天,Jiajia.Wind和孩子们决定在家里玩捉迷藏游戏 ...
- [NOIP2016]天天爱跑步(树上差分+线段树合并)
将每个人跑步的路径拆分成x->lca,lca->y两条路径分别考虑: 对于在点i的观察点,这个人(s->t)能被观察到的充要条件为: 1.直向上的路径:w[i]=dep[s]-dep ...
- 【拓扑排序】【bitset】Gym - 101128A - Promotions
给你一张DAG,若选择u点,则必须先选择所有能到达其的点.问你在选择A个点的情况下,哪些点必选:选择B个点的情况下,哪些点必选:选择B个点的情况下,哪些点一定不选. 选择A个点的情况,必选的点是那些其 ...