Skip to content

Instantly share code, notes, and snippets.

@kixxauth kixxauth/main.html
Created Jul 10, 2013

What would you like to do?
Link to Twitter App from iBooks Widget
<!DOCTYPE html>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="style.css">
<div id="container">
<h1>Link to an External iOS App</h1>
<section class="static-tweet">
<h3 class="header">
Post a tweet with a static link.
<p class="content">
<a href="twitter://post?message=This%20tweet%20was%20posted%20from%20your%20iBook">Post a tweet to the Twitter App</a>
<section class="dynamic-tweet">
<h3 class="header">
Post a tweet with dynamic content.
<p class="content">
<label for="twitter-post">Create a Tweet:</label>
<textarea id="twitter-post"></textarea>
<p class="content">
<button onclick="postToTwitter()">Post it!</button>
<script type="text/javascript" src="js/script.js" charset="utf-8"></script>
// This function is invoked when the button is pushed.
function postToTwitter () {
// Get the tweet content from the HTML text area.
var tweet = document.getElementById('twitter-post').value;
// Encode the tweet content to send it to the Twitter app
// (puts in the '%' symbols where needed).
tweet = encodeURI(tweet);
// Create the link.
var url = 'twitter://post?message=' + tweet;
// Open the link.
window.location.href = url;
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.