我使用以下代码在我的博客中添加了一个 Twitter 分享按钮:
<a class="twitter popup" href="http://twitter.com/share?text=mytext">Tweet Me</a>
然后我在弹出窗口中打开它:
<script type="text/javascript">
$('.popup').click(function(event) {
var width = 575,
height = 400,
left = ($(window).width() - width) / 2,
top = ($(window).height() - height) / 2,
url = this.href,
opts = 'status=1' +
',width=' + width +
',height=' + height +
',top=' + top +
',left=' + left;
window.open(url, 'twitte', opts);
return false;
});</script>
有一种方法可以设置弹出窗口的样式吗?我想要带有 Twitter 表单的样式化弹出窗口。
最佳答案
如果您想完全控制外观,那么 Twitter 的@anywhere Tweet Box是你需要实现的。好吧,要么那样做,要么获取一个 Twitter 客户端库并推出你自己的方法。
使用@anywhere 需要您在 dev.twitter.com 上设置应用程序,并且您的用户将需要授权您的应用发布推文,但这是您为灵 active 付出的代价。
推特 Web Intents可能是您的替代方案,但弹出窗口中显示的布局将是 Twitter 的,而不是您的。但是,值得一提的是,您没有申请注册要求。
Web Intents provide popup-optimized flows for working with Tweets & Twitter Users: Tweet, Reply, Retweet, Favorite, and Follow. They make it possible for users to interact with Twitter content in the context of your site, without leaving the page or having to authorize a new app just for the interaction.
关于javascript - 如何设计 Twitter 弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6342733/