Skip to content

Instantly share code, notes, and snippets.

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

Embed
What would you like to do?
Link to Twitter App from iBooks Widget
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="style.css">
</head>
<body>
<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.
</h3>
<p class="content">
<a href="twitter://post?message=This%20tweet%20was%20posted%20from%20your%20iBook">Post a tweet to the Twitter App</a>
</p>
</section>
<section class="dynamic-tweet">
<h3 class="header">
Post a tweet with dynamic content.
</h3>
<p class="content">
<label for="twitter-post">Create a Tweet:</label>
<textarea id="twitter-post"></textarea>
</p>
<p class="content">
<button onclick="postToTwitter()">Post it!</button>
</p>
</section>
</div>
<script type="text/javascript" src="js/script.js" charset="utf-8"></script>
</body>
</html>
// 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.