Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Generate Tweet Intent URL
<!DOCTYPE html>
<link href="" rel="stylesheet">
<script src=""></script>
<title>twitter link gen</title>
$(function() {
$("#twtgen").submit(function() {
var url = '';
var params = '?'
$('#twtgen input').each(function(i) {
if ($(this).val()) {
var param = $(this).attr('name') + '=' + encodeURIComponent($(this).val());
params = params + param + '&';
params = params.replace(/&$/,'');
$("#tweetLink").val(url + params);
return false;
$("#tweetLink").click(function() {
<div class="container">
<h1>Tweet Link Generator</h1>
<p>Generates a <a href=''>Tweet Web Intent</a> URL. Makes it easy to add
a tweet link without additional javascript of iframes from Twitter.</p>
<form id="twtgen">
<div class='form-group'>
<label>Tweet Text</label>
<input type='text' class='form-control' id='tweetText' name='text'>
<div class='form-group'>
<label>Tweet URL</label>
<input type='text' class='form-control' id='tweetUrl' name='url'>
<div class='form-group'>
<input type='text' class='form-control' id='tweetHashtags' name='hashtags'>
<div class='form-group'>
<input type='text' class='form-control' id='tweetVia' name='via'>
<div class='form-group'>
<input type='text' class='form-control' id='tweetRelated' name='related'>
<div class='form-group'>
<input type='text' class='form-control' id='tweetReply' name='in-reply-to'>
<button type="submit" class="btn btn-primary">Generate</button>
<div class='form-group'>
<label>Tweet Link</label>
<input type='text' class='form-control' id='tweetLink'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.