views:

474

answers:

2

Hi stackoverflowers,

I'm just trying to put the custom twitter's profile widget on my page, but I like to put the code in a separate javascript's file.

so, I don't know how to do that.

I mean, I put this on head tag

<script type="text/javascript" src="http://widgets.twimg.com/j/2/widget.js"&gt;&lt;/script&gt;

the create a div for the widget, an put the rest of the code in another javascript

new TWTR.Widget(json_twitter_options).render().setUser('username').start();

But, how to "put" the result in that widget... I'm totally lost, thanks in advance.

A: 

The js file doesn't have to be in the head just above the widget

this code works I have tested it:

<script src="http://widgets.twimg.com/j/2/widget.js"&gt;&lt;/script&gt; 
<script> 
new TWTR.Widget({
  version: 2,
  type: 'profile',
  rpp: 4,
  interval: 6000,
  width: 135,
  height: 700,
  theme: {
    shell: {
      background: '#e5e5e5',
      color: '#363F49'
    },
    tweets: {
      background: '#e5e5e5',
      color: '#000000',
      links: '#06C'
    }
  },
  features: {
    scrollbar: false,
    loop: false,
    live: false,
    hashtags: true,
    timestamp: true,
    avatars: false,
    behavior: 'all'
  }
}).render().setUser('USERNAME').start();
</script>
jason
thanks Jason for your answer, but that's not true... I can put the first <script> on head, and works, pretty well.. now, maybe I miss something, but what I want is put the second <scrip> in a separate javascript file... listen, I already know that your code works well, but my html is pretty big enough, I just want to find another way in a separate javascript file.
raulricardo21
A: 

Ok, It seem my question was not understand.

I couldn't do what I want. But the way to simplify my problem, was creating a json object for setting up the widget.

I'm still want to find a way to not use script tag inside body tag

thanks a lot to viewvers!

raulricardo21