javascript - 如何设计 Twitter 弹出窗口

标签 javascript jquery twitter popup

我使用以下代码在我的博客中添加了一个 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/

相关文章:

javascript - 使用 react-native-ble-manager 获取可用蓝牙设备的列表

javascript - 每过一分钟就重新加载页面

javascript - 在响应式设计中将 3 个菜单合并为一个菜单

php - 使用 jQuery 将 php 文件加载到 div 中不起作用

JQuery SlideUp 和 SlideDown 在 Chrome 中无法正常工作

c# - 我可以从 Twitter Digits 回调中获取电话号码吗?

python - 推特/通用分类训练语料库

javascript - 动态按钮不调用javascript函数?

javascript - require.js - 如何将所需模块的版本设置为 URL 的一部分?

ios - 类似 Twitter 的 UITableView 设计