[英]Display A Random User Profile In Twitter Widget
I have six twitter user names which I would like to display on my page. 我有六个Twitter用户名,我想在页面上显示它们。 Rather than display all six at once, I want to just pick one randomly and show one at a time.
我不想一次显示所有六个,而是想随机选择一个,然后一次显示一个。
I'm having trouble updating the twitter widget after page load, however. 但是,在页面加载后无法更新twitter小部件。 The last line of the widget calls the function setUser() like so:
小部件的最后一行调用函数setUser(),如下所示:
}).render().setUser(document.getElementById("TWITTER_PROFILE_HERE").value).start();
How can I change the TWITTER_PROFILE_HERE to the specific name that I've chosen randomly? 如何将TWITTER_PROFILE_HERE更改为我随机选择的特定名称?
Thanks in advance. 提前致谢。
FYI here is the link to the create a widget page: http://twitter.com/about/resources/widgets/widget_profile 仅供参考,下面是创建小部件页面的链接: http : //twitter.com/about/resources/widgets/widget_profile
Just make sure to change the var username to whatever you want. 只需确保将var用户名更改为所需的任何名称即可。
<script>
var username = "WHATEVER_USERNAME"; // Add this line in to determine which username you want.
new TWTR.Widget({
...
}).render().setUser(username).start();
</script>
Or if you want to select one random name from all of your names. 或者,如果您想从所有名称中选择一个随机名称。
<script>
var usernames = ['user_1', 'user_2', 'user_3', 'user_4'];
var username = usernames[Math.floor(Math.random()*usernames.length)];
new TWTR.Widget({
...
}).render().setUser(username).start();
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.