JavaScript - 显示来自textfield的关注者

时间:2013-01-12 08:57:55

标签: javascript

我想在这里显示来自Twitter的关注者:

enter image description here
所以,当我用任何用户名填充文本字段时 关注者的结果将显示在底部

这是我的代码:

  • 的index.html

    <html>
    <head>
    <start twitter fan box –>
    <script type="text/javascript" src="script.js"></script>
    <title></title>
    </head>
    <body>
    <div id="twitterfanbox">
    <script type="text/javascript">fanbox_init("your_username");
    </script type="text">
    </start>
    </div id="twitterfanbox"> 
    </body>
    </html> 
    
  • 的script.js

  

功能   fanbox_init(SCREEN_NAME){的document.getElementById( 'twitterfanbox')。的innerHTML =

    '\<iframe name=\"fbfanIFrame_0\" frameborder=\"0\" allowtransparency=\"true\"
src=\"http://s.moopz.com/connect.html?user='+screen_name+'\" class=\"FB_SERVER_IFRAME\" scrolling=\"no\" style=\"width: 300px; height: 250px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; \"\>\<\/iframe\>';}

1 个答案:

答案 0 :(得分:1)

您现在总是将字符串文字“your_username”传递给fanbox_init:fanbox_init("your_username")

尝试fanbox_init(prompt("what is your Twitter username?")) - 或作为两个陈述:

var username = prompt("what is your Twitter username?");
fanbox_init(username);

这将显示一个提示(允许用户输入一行文本的弹出框)并将该值传递给fanbox_init