3

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?

4

1 回答 1

1

这真的可能不是最好的方法,但我需要同样的东西并且必须快速完成。第一个调用端口是 twitter API,我期望它应该如何完成。但是时间限制意味着我已经这样做了:

HTML:

<textarea class="tweetmsg"></textarea>
<a href="https://twitter.com/share?text=original tweet text" class="twitter-share-button" target="_blank">Tweet</a>

然后每次按下一个键时,使用 jQuery 填充推文按钮数据文本属性。

$('textarea.tweetmsg').keyup(function() {
    var tweetmsg = $('textarea.tweetmsg').val();
    $('.twitter-share-button').attr('href', 'https://twitter.com/share?text=' + tweetmsg);
});

就像我说的那样,这可能是一种非常低效的方法,因为每次按下键时它都会重新填充数据文本字段。如果有人可以改进上述解决方案,我会很感兴趣。

于 2013-03-21T11:58:35.890 回答