javascript 如何风格 Twitter 弹出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6342733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How Style Twitter popup
提问by Andref
I added a Twitter share button into my blog using the below code:
我使用以下代码在我的博客中添加了一个 Twitter 共享按钮:
<a class="twitter popup" href="http://twitter.com/share?text=mytext">Tweet Me</a>
and I open it in a popup with:
我在弹出窗口中打开它:
<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>
There is a way to style the popup? I want my styled popup with the twitter form in it.
有没有办法设置弹出窗口的样式?我想要带有 twitter 表单的样式弹出窗口。
回答by arcain
If you want complete control over the look and feel, then Twitter's @anywhere Tweet Boxis what you would need to implement. Well, either that or get a Twitter client library and roll your own approach.
如果您想完全控制外观,那么您需要实现Twitter 的@anywhere Tweet Box。好吧,要么得到一个 Twitter 客户端库并推出你自己的方法。
Using @anywhere will require you to set up an application on dev.twitter.com, and your users will need to authorize your app to post a tweet, but that's the price you pay for flexibility.
使用@anywhere 将要求您在dev.twitter.com上设置一个应用程序,您的用户需要授权您的应用程序发布推文,但这是您为灵活性付出的代价。
Twitter Web Intentscould be an alternative for you, but the layout displayed in your popup would be Twitter's, not yours. It is, however, worth mentioning since you don't have the application registration requirement.
Twitter 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.
Web Intent 为与推文和 Twitter 用户一起工作提供了弹出优化的流程:推文、回复、转推、收藏和关注。它们使用户可以在您网站的上下文中与 Twitter 内容进行交互,而无需离开页面或仅为交互而授权新应用程序。
回答by Kon
If you're just opening page content in a standard browser window/tab, you don't have much control over how that looks. You can get more control and styling options if you pop it up in the same browser window, but perhaps in a lightbox fashion. Here are some lightboxy jQuery plugins that you may want to check out:
如果您只是在标准浏览器窗口/选项卡中打开页面内容,则无法控制其外观。如果您在同一浏览器窗口中弹出它,您可以获得更多控制和样式选项,但可能以灯箱方式弹出。以下是一些您可能想要查看的 Lightboxy jQuery 插件:
http://line25.com/articles/rounding-up-the-top-10-jquery-lightbox-scripts
http://line25.com/articles/rounding-up-the-top-10-jquery-lightbox-scripts
回答by Bojan Bjelic
Why don't you use the "Tweet Button" provided by Twitter and it will take care of everything...
你为什么不使用 Twitter 提供的“推文按钮”,它会处理一切......
回答by Felix
You can:
你可以:
- Use the Twitter API to post messages on behalf of your users. This way you get full control over the functionality / markup, but it also means having your users authorize your app, and most users are resilient to that.
- Create a
<form>
that has the same input elements / names as the twitter page (http://twitter.com/intent/tweet?text=mytext). This is bound to break because they can change the required parameters at any time and without warning.
- 使用 Twitter API 代表您的用户发布消息。通过这种方式,您可以完全控制功能/标记,但这也意味着让您的用户授权您的应用程序,并且大多数用户对此具有弹性。
- 创建一个
<form>
与 Twitter 页面 ( http://twitter.com/intent/tweet?text=mytext)具有相同输入元素/名称的文件。这势必会中断,因为他们可以随时更改所需的参数,而不会发出警告。
However:I do not recommend any of these, as both will drive users away. The default and official Twitter page is familiar to them and they are more likely to post something from it. Also, being on the twitter.com
domain gives them (well, some of them) a sense of security.
但是:我不推荐其中任何一种,因为两者都会使用户望而却步。默认的官方 Twitter 页面对他们来说很熟悉,他们更有可能从中发布一些内容。此外,在twitter.com
域中会给他们(好吧,其中一些)一种安全感。