Skip to content
Create a gist now

Instantly share code, notes, and snippets.

<!-- load this in head
<script src=""></script>
data-intent-text="The quick brown fox jumps over the lazy dog."
<p>* note: This does not work on jsfiddle because of x-frame-options. </p>
* $.fn.twttrintent
* see following about intent api
$.fn.twttrintent = function(options){
function attachDataVal($el, attrKey, finalKey, obj){
var val = $;
if (val === undefined){
return obj;
obj[finalKey] = val;
return obj;
return this.each(function(){
var $el = $(this);
var dataVals = {};
attachDataVal($el, 'intentText', 'text', dataVals);
attachDataVal($el, 'intentUrl', 'url', dataVals);
attachDataVal($el, 'intentHashtags', 'hashtags', dataVals);
var data = $.extend({}, options, dataVals);
var paramstr = $.param(data);
$el.attr('href', $el.attr('href') + '?' + paramstr);
/* fire */
// twitter intent
name: $.fn.twttrintent
description: post to twitter using twitter intent api
- Takeshi Takatsudo
normalize_css: no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.