Reputation: 24087
Having Googled myself dry I'm going to try here, although it may be impossible.
I simply want to embed a tweet box in one of my web pages, using the web intent API which provides the content in page: https://twitter.com/intent/tweet.
The trouble is, using this url within an iFrame results in it not working, presumably because this functionality has been disabled by the Twitterati. It does say the web intents API is intended to be a popup but is there a way around this or am I forced to go with a link that produces a popup window?
Upvotes: 3
Views: 2804
Reputation: 13
This is really probably not the best way to do this, but I needed the same thing and had to do it quickly. First port of call was the twitter API which I expect is how it SHOULD be done. But time constraints meant I've done it like this:
HTML:
<textarea class="tweetmsg"></textarea>
<a href="https://twitter.com/share?text=original tweet text" class="twitter-share-button" target="_blank">Tweet</a>
Then with jQuery populate the tweet buttons data-text attribute each time a key is pressed.
$('textarea.tweetmsg').keyup(function() {
var tweetmsg = $('textarea.tweetmsg').val();
$('.twitter-share-button').attr('href', 'https://twitter.com/share?text=' + tweetmsg);
});
Like I say this is probably a very inefficient way of doing it, as it re-populates the data-text field each time a key is pressed. I'd be interested if anyone can improve on the above solution.
Upvotes: 1